【发布时间】:2018-04-26 12:37:17
【问题描述】:
我目前正在使用波兰财政部的官方 API 开发客户端应用程序来检查 NIP 编号。 (https://sprawdz-status-vat.mf.gov.pl/?wsdl) 不幸的是,我对他们发布的 wsdl 有疑问。即有一条包含两部分的消息。
<wsdl:message name="SprawdzNIPNaDzienZapytanie">
<wsdl:part name="NIP" element="tns:NIP"/>
<wsdl:part name="Data" element="tns:Data"/>
</wsdl:message>
我试图通过wsimport maven 插件解析它,但客户端代码甚至没有生成,因为错误
[ERROR] operation "SprawdzNIPNaDzien": more than one part bound to body[ERROR] operation "SprawdzNIPNaDzien": more than one part bound to body
我想好吧,我会尝试不同的工具来生成代码。由于我之前已经使用过 cxf,所以我选择使用它。代码生成得很好,但是当我尝试调用该服务时,我确实遇到了与以前类似的错误。
SEI WeryfikacjaVAT has method sprawdzNIPNaDzien annotated as BARE but it has more than one parameter bound to body. This is invalid. Please annotate the method with annotation: @SOAPBinding(parameterStyle=SOAPBinding.ParameterStyle.WRAPPED)
现在我想知道。有没有办法在不更改 wsdl 文件的情况下使其工作?由于它是不属于我的官方 API,我无法更正它。我想必须通过某种方式来使用诸如 SoapUI 之类的 wsdl 来处理它并且不会引发任何错误。
@更新
我尝试添加 Khalid 提到的 cxf 参数,所以我的 pom.xml 如下所示:
<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>
<defaultOptions>
</defaultOptions>
<sourceRoot>${project.build.directory}/generated-sources/cxf</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>other.xml</wsdl>
</wsdlOption>
<wsdlOption>
<wsdl>${basedir}/src/main/resources/wsdl/my.wsdl</wsdl>
<bindingFiles>
<bindingFile>
${basedir}/src/main/resources/wsdl/bindings.xml
</bindingFile>
</bindingFiles>
<noAddressBinding>true</noAddressBinding>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
还有bindings.xml文件:
<jaxws:bindings
wsdlLocation="my.wsdl"
xmlns="http://java.sun.com/xml/ns/jaxws"
xmlns:jaxws="http://java.sun.com/xml/ns/jaxws">
<enableWrapperStyle>true</enableWrapperStyle>
</jaxws:bindings>
不幸的是,仍然使用
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)而不是WRAPPED注释生成端口。
【问题讨论】:
标签: java soap wsdl cxf wsimport