0

我们正面临使用 apache cxf-codegen-plugin 从 wsdl 生成正确 SOAP 请求的问题。客户端触发的请求缺少 SOAP 信封和 SOAP 正文标记。这是我们必须以编程方式做的事情,还是可以在插件额外参数中配置的事情。重现步骤 1. 在 pom 中包含 cxf-codegen-plugin maven 插件版本 3.0.3 2. 在生成源期间,会生成源。

当请求被触发时,它看起来像这样

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><CalculateSomething xmlns="http://something/0.3.1/" xmlns:ns2="http://something/0.1/" xmlns:ns3="http://something"></CalculateSomething>

而不是当我们通过 POSTMAN 尝试(并且它成功)时,应该生成的请求是

<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
  <S:Body>
    <ns3:CalculateSomething xmlns:ns4="http://schemas.microsoft.com/2003/10/Serialization/" xmlns:ns3="http://something" xmlns:ns2="http://something" xmlns="http://something/0.1/">
      <ns3:request>...
    </ns3:CalculateSomething>
  </S:Body>
</S:Envelope>

基本上看起来我们无法通过 cxf codegen 插件正确生成 SOAP 信封,或者我们没有正确配置它。我们在 pom 中有这个。

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.2</version>
        <configuration>
            <source>1.8</source>
            <target>1.8</target>
        </configuration>
    </plugin>
    <plugin>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-codegen-plugin</artifactId>
        <version>${cxf.version}</version>
        <executions>
            <execution>
                <id>generate-sources</id>
                <phase>generate-sources</phase>
                <configuration>
                    <sourceRoot>${project.build.directory}/generated-sources/cxf</sourceRoot>
                    <wsdlOptions>
                        <wsdlOption>
                            <wsdl>${basedir}/src/main/resources/wsdl/something.wsdl</wsdl>
                        </wsdlOption>
                    </wsdlOptions>
                </configuration>
                <goals>
                    <goal>wsdl2java</goal>
                </goals>
            </execution>
        </executions>
    </plugin>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <version>1.12</version>
            <executions>
                <execution>
                    <id>add-source</id>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>add-source</goal>
                    </goals>
                    <configuration>
                        <sources>
                            <source>${basedir}/target/generated-sources/jaxb</source>
                        </sources>
                    </configuration>
                </execution>
            </executions>
        </plugin>
4

0 回答 0