I'm currently developing client app using official API of Polish Ministry of Finance to check NIP numbers. (https://sprawdz-status-vat.mf.gov.pl/?wsdl) Unfortunately I have a problem with wsdl published by them. Namely there is a message with 2 parts.
<wsdl:message name="SprawdzNIPNaDzienZapytanie">
<wsdl:part name="NIP" element="tns:NIP"/>
<wsdl:part name="Data" element="tns:Data"/>
</wsdl:message>
I was trying to parse it by wsimport
maven plugin but client side code didn't even generate, because of error
[ERROR] operation "SprawdzNIPNaDzien": more than one part bound to body[ERROR] operation "SprawdzNIPNaDzien": more than one part bound to body
I thought ok, I will try different tool for generating code. As I have already used cxf earlier I chose to use it. Code generated just fine but when I was trying to call the service I did get similar error as before.
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)
Now I'm wondering. Is there a way to make it work without changing wsdl file? As it is official API which doesn't belong to me, I have no way to correct it. I guess there must by a way to operate with such wsdl as SoapUI handle it just fine and doesn't throw any errors.
@Update
I have tried to add cxf parameter mentioned by Khalid so my pom.xml looks as follows:
<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>
And bindings.xml
file:
<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>
Unfortunately port is still generated with
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
instead of WRAPPED annotation.