I'm implementing a simple client using apache cxf and the codegen maven plugin (both release 3.1.11).
Here is my sample wsdl:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="urn:webServiceTest" xmlns:s0="urn:webServiceTest" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<wsdl:types>
<xsd:schema elementFormDefault="qualified" targetNamespace="urn:webServiceTest">
<xsd:element name="OpenTk" type="s0:InputMapping1"/>
<xsd:complexType name="InputMapping1">
<xsd:sequence>
<xsd:element minOccurs="0" name="ID_NOTIFICA" type="xsd:string"/>
<xsd:element minOccurs="0" name="ID_MESSAGGIO" type="xsd:string"/>
<xsd:element minOccurs="0" name="DATA_ID_NOTIFICA" type="xsd:dateTime"/>
<xsd:element minOccurs="0" name="DATA_ID_MESSAGGIO" type="xsd:dateTime"/>
<xsd:element minOccurs="0" name="ID_RISORSA" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="APERTURATKResponse" type="s0:OutputMapping1"/>
<xsd:complexType name="OutputMapping1">
<xsd:sequence>
<xsd:element minOccurs="0" name="CODICE" type="xsd:string"/>
<xsd:element minOccurs="0" name="DESCRIZIONE" type="xsd:string"/>
<xsd:element minOccurs="0" name="NOTE" nillable="true" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="AuthenticationInfo" type="s0:AuthenticationInfo"/>
<xsd:complexType name="AuthenticationInfo">
<xsd:sequence>
<xsd:element name="userName" type="xsd:string"/>
<xsd:element name="password" type="xsd:string"/>
<xsd:element minOccurs="0" name="authentication" type="xsd:string"/>
<xsd:element minOccurs="0" name="locale" type="xsd:string"/>
<xsd:element minOccurs="0" name="timeZone" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
</wsdl:types>
<wsdl:message name="OpenTkSoapOut">
<wsdl:part element="s0:APERTURATKResponse" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:message name="OpenTkSoapIn">
<wsdl:part element="s0:OpenTk" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:message name="ARAuthenticate">
<wsdl:part element="s0:AuthenticationInfo" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:portType name="New_Port_0PortType">
<wsdl:operation name="OpenTk">
<wsdl:input message="s0:OpenTkSoapIn">
</wsdl:input>
<wsdl:output message="s0:OpenTkSoapOut">
</wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="New_Port_0SoapBinding" type="s0:New_Port_0PortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="OpenTk">
<soap:operation soapAction="urn:webServiceTest/OpenTk" style="document"/>
<wsdl:input>
<soap:header message="s0:ARAuthenticate" part="parameters" use="literal">
</soap:header>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="WebServicesFWCFFService">
<wsdl:port binding="s0:New_Port_0SoapBinding" name="New_Port_0Soap">
<soap:address location="http://localhost:9090/testService"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
I need to change client endpoint so I decided to use cxf.frontend feature. I created a simple Client and I used the api to set the address property. Here is the code:
QName SERVICE = new QName("urn:webServiceTest", "WebServicesFWCFFService");
URL url = this.getClass().getClassLoader().getResource("testWsdl.wsdl").toURI().toURL();
NewPort0PortType portType = new WebServicesFWCFFService(url, SERVICE).getNewPort0Soap();
Client client = ClientProxy.getClient(portType);
client.getRequestContext().put(Message.ENDPOINT_ADDRESS,address);
Then inside my unit tests I try to invoke the service (the service created by codegen plugin) doing:
ClientTest client = new ClientTest();
Holder<String> code= new Holder<>();
Holder<String> description= new Holder<>();
Holder<String> notes= new Holder<>();
client.portType.openTk("12","",
null,null,"1",code, description, notes);
assertNotNull(notes.value);
assertNotNull(code.value);
but I receive a soap fault org.apache.cxf.binding.soap.SoapFault: wrong number of arguments while invoking public void it.test.cxf.impl.New_Port_0SoapImpl.openTk.
I found that the problem seems to be inside org.apache.cxf.jaxws.interceptors.WrapperClassOutInterceptor and in particular when this interceptor create a WrapperHelper class using the method getHelperWrapper. Then uses this wrapper to create the object using the ObjectFactory created by codegen plugin (createWrapperObject(objs);). This results in a new InputMappin1 object with all filds null.
Can someone explane me this behaviour and how I can avoid this? Do I need to implement some kind of custom interceptor or I'm missing some configuration?