I'm facing an issue and after few days searching for an answer I decided it's better to ask for online help.
So I have WSDL from a client I can't modify. I put here an equivalent version :
<?xml version="1.0" encoding="UTF-8"?>
<definitions
xmlns:tns="http://apache.org/handlers"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:x1="http://apache.org/handlers/types"
name="WsdlInvestigation"
targetNamespace="http://apache.org/handlers">
<types>
<xsd:schema
xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://apache.org/handlers/types"
elementFormDefault="qualified">
<complexType name="getSomeDataParam">
<sequence>
<element name="inputParam" type="xsd:string" minOccurs="1" maxOccurs="unbounded"/>
</sequence>
</complexType>
<complexType name="getSomeDataResponse">
<sequence>
<element name="return" type="xsd:int"/>
</sequence>
</complexType>
<complexType name="FaultDetail">
<sequence>
<element name="faultInfo" type="xsd:string"/>
<element name="message" type="xsd:string"/>
</sequence>
</complexType>
</xsd:schema>
</types>
<message name="getSomeDataRequest">
<part name="parameters" type="x1:getSomeDataParamType"/>
</message>
<message name="getSomeDataResponse">
<part name="result" type="x1:getSomeDataResponseType"/>
</message>
<message name="wsdlInvestigationFault">
<part name="faultDetail" type="x1:FaultDetailType" />
</message>
<portType name="WsdlInvestigationPortType">
<operation name="getSomeData">
<input message="tns:getSomeDataRequest"/>
<output message="tns:getSomeDataResponse"/>
<fault name="wsdlInvestigationFault" message="tns:wsdlInvestigationFault"/>
</operation>
</portType>
<binding name="WsdlInvestigationBinding" type="tns:WsdlInvestigationPortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<operation name="getSomeData">
<soap:operation soapAction="getSomeData"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
<fault name="wsdlInvestigationFault">
<soap:fault name="wsdlInvestigationFault" use="literal"/>
</fault>
</operation>
</binding>
<service name="WsdlInvestigationService">
<port name="WsdlInvestigationPort" binding="tns:WsdlInvestigationBinding">
<soap:address location="http://localhost:9000/handlers/WsdlInvestigationService/WsdlInvestigationPort"/>
</port>
</service>
</definitions>
When I put my WSDL in SoapUi, I can create request like that:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:typ="http://apache.org/handlers/types">
<soapenv:Header/>
<soapenv:Body>
<parameters>
<!--1 or more repetitions:-->
<typ:inputParam>?</typ:inputParam>
</parameters>
</soapenv:Body>
</soapenv:Envelope>
I am using the maven cxf-codegen-plugin plugin to generate the sources. Here is a piece of my pom.xml
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf.version}</version>
<executions>
<execution>
<id>generate-SOAPService1</id>
<phase>generate-sources</phase>
<configuration>
<wsdlOptions>
<wsdlOption>
<wsdl>${wsdl.file}</wsdl>
<bareMethods/>
<extraargs>
<!-- Add "toString" to objects -->
<extraarg>-xjc-Xts</extraarg>
</extraargs>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.9.1</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-xjc-ts</artifactId>
<version>2.2.12</version>
</dependency>
</dependencies>
</plugin>
The generated service is like that :
@WebService(targetNamespace = "http://apache.org/handlers", name = "WsdlInvestigationPortType")
@XmlSeeAlso({org.apache.handlers.types.ObjectFactory.class})
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
public interface WsdlInvestigationPortType {
@WebMethod(action = "getSomeData")
@WebResult(name = "result", targetNamespace = "", partName = "result")
public org.apache.handlers.types.GetSomeDataResponseType getSomeData(
@WebParam(partName = "parameters", name = "parameters", targetNamespace = "")
org.apache.handlers.types.GetSomeDataParamType paramPackage
) throws WsdlInvestigationFault;
}
As we can see, the "getSomeData" method is using a parameter "GetSomeDataParamType".
If we go into the GetSomeDataParamType class, we won't see the class annotated with the @XmlRootElement so I can't marshall my "request" object with jaxb and end up with an exception.
The problem is I can't modify the WSDL.
What could I do to generate the proper service method and the proper classes that could be marshalled ?
I tried some tuning with Jaxb but no success.
Thanks in advance for your support