I'm currently updating a old axis wsclient to a cxf(jaxb databinding) client,
now there are differences, how list/array are handled.
Let me explain that on an example:
wsdl
<xsd:complexType name="ArrayOfString">
<xsd:sequence>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="string" nillable="true" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
which is in a other complexType
<xsd:complexType name="CustomParameter">
<xsd:sequence>
<xsd:element minOccurs="0" name="values" nillable="true" type="tns:ArrayOfString"/>
</xsd:sequence>
</xsd:complexType>
now when trying to access this attribute in cxf it is needed to additionally get the value from the list-wrapper
CustomParameter.getValues().getString(); // returns List<String>
Axis does afaik unwrap this automatically that you got the array only with
CustomParameter.getValues() // returns String[]
My question is, is this possible to do this in cxf?
A part of my wsdl:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://ws611.webservice.adapters.company.de" xmlns:soapenc11="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://ws611.webservice.adapters.company.de" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns2="http://usermanagement.ws611.webservice.company.de"
xmlns:ns1="http://ws611.webservice.company.de" xmlns:soapenc12="http://www.w3.org/2003/05/soap-encoding">
<wsdl:types>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://ws611.webservice.company.de">
<xsd:complexType name="AuthenticationToken">
<xsd:sequence>
<xsd:element minOccurs="0" name="password" nillable="true" type="xsd:string"/>
<xsd:element minOccurs="0" name="timestamp" nillable="true" type="xsd:string"/>
<xsd:element minOccurs="0" name="username" nillable="true" type="xsd:string"/>
</xsd:sequence>
<xsd:anyAttribute/>
</xsd:complexType>
</xsd:schema>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://ws611.webservice.adapters.company.de">
<xsd:element name="getAllUsers">
<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="1" name="in0" nillable="true" type="ns1:AuthenticationToken"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="getAllUsersResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="1" name="out" nillable="true" type="ns2:ArrayOfUser"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://usermanagement.ws611.webservice.company.de">
<xsd:complexType name="ArrayOfUser">
<xsd:sequence>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="User" nillable="true" type="ns2:User"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="User">
<xsd:sequence>
<xsd:element minOccurs="0" name="name" nillable="true" type="xsd:string"/>
<xsd:element minOccurs="0" name="groups" nillable="true" type="ns2:ArrayOfGroup"/>
</xsd:sequence>
<xsd:anyAttribute/>
</xsd:complexType>
<xsd:complexType name="ArrayOfGroup">
<xsd:sequence>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="Group" nillable="true" type="ns2:Group"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="Group">
<xsd:sequence>
<xsd:element minOccurs="0" name="name" nillable="true" type="xsd:string"/>
</xsd:sequence>
<xsd:anyAttribute/>
</xsd:complexType>
</xsd:schema>
</wsdl:types>
<wsdl:message name="getAllUsersRequest">
<wsdl:part name="parameters" element="tns:getAllUsers">
</wsdl:part>
</wsdl:message>
<wsdl:message name="getAllUsersResponse">
<wsdl:part name="parameters" element="tns:getAllUsersResponse">
</wsdl:part>
</wsdl:message>
<wsdl:portType name="UserManagementPortType">
<wsdl:operation name="getAllUsers">
<wsdl:input name="getAllUsersRequest" message="tns:getAllUsersRequest">
</wsdl:input>
<wsdl:output name="getAllUsersResponse" message="tns:getAllUsersResponse">
</wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="UserManagementHttpBinding" type="tns:UserManagementPortType">
<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="getAllUsers">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="getAllUsersRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="getAllUsersResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="UserManagement">
<wsdl:port name="UserManagementHttpPort" binding="tns:UserManagementHttpBinding">
<wsdlsoap:address location="http://localhost:8080/test/webservice/ws611/UserManagement"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
It is possible to get the cxf-codegen-plugin to generate model classes that automatically hide XML element wrapper classes.
There are three things you need to use:
A custom JAXB binding file that suppresses usage of JAXBElement
For any PortTypes, a custom JAXWS binding file that makes sure to use your request and response classes directly
The jaxb-xew-plugin to generate #XmlElementWrapper annotations, which is the JAXB annotation for designating lists as wrapped
Here is what the custom JAXB binding file should look like:
<jaxb:bindings version="2.1" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb">
<jaxb:globalBindings generateElementProperty="false"/>
</jaxb:bindings>
Here is what the custom JAXWS binding file should look like:
<jaxws:bindings xmlns:jaxws="http://java.sun.com/xml/ns/jaxws">
<jaxws:enableWrapperStyle>false</jaxws:enableWrapperStyle>
</jaxws:bindings>
Here is a sample working usage of the cxf-codegen-plugin using JAXB and JAXWS binding files and the jaxb-xew-plugin:
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>3.1.4</version>
<executions>
<execution>
<id>generate-client</id>
<phase>generate-sources</phase>
<configuration>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/src/main/resources/sample.wsdl</wsdl>
<bindingFiles>
<bindingFile>${basedir}/src/main/resources/jaxbBinding.xml</bindingFile>
<bindingFile>${basedir}/src/main/resources/jaxwsBinding.xml</bindingFile>
</bindingFiles>
<extraargs>
<extraarg>-xjc-Xxew</extraarg>
<extraarg>-xjc-Xxew:summary
${project.build.outputDirectory}/../xew-summary.txt
</extraarg>
<extraarg>-xjc-Xxew:instantiate lazy</extraarg>
</extraargs>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.github.jaxb-xew-plugin</groupId>
<artifactId>jaxb-xew-plugin</artifactId>
<version>1.6</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-xjc</artifactId>
<version>2.2.11</version>
</dependency>
</dependencies>
</plugin>
This configuration will generate the following on the schema provided in the question:
CustomParameter.getValues() // returns List<String>
Note that this does NOT return a String[]. You could get the cxf-codegen-plugin to use a String[] instead of a List<String> by adding a collectionType="indexed" attribute to your globalBindings, but currently the jaxb-xew-plugin only supports Collection types and not arrays.
Related
I have two different WSDL's for same process. First one is giving three packages on wsimport while seconds one is giving two packages on wsimport. I think both of the wsdl are from different versions but I am sure that both have same functionality.
The first one with three packages is working fine for me but second one is giving error i. e SOAP error given in image. I have searched and worked every possibility but still I am standing at the same issue. Do anyone know what will be the working solution ?
First wsdl
<?xml version="1.0" encoding="UTF-8" ?>
- <!-- Published by JAX-WS RI (http://jax-ws.java.net). RI's version is JAX-WS RI 2.3.0-b170407.2038 svn-revision#2eaca54d17a59d265c6fe886b7fd0027836c766c.
-->
- <wsdl:definitions xmlns:tns="http://ouaf.oracle.com/webservices/c1/C1-AccountMail" xmlns:ouaf="http://ouaf.oracle.com/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" name="C1-AccountMail" targetNamespace="http://ouaf.oracle.com/webservices/c1/C1-AccountMail" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wssutil="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsp:UsingPolicy wssutil:Required="true" />
<wsdl:documentation>C1-AccountMail version 1: Retrieve an Account's Mailing Address</wsdl:documentation>
- <wsdl:types>
- <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ouaf="http://ouaf.oracle.com/" targetNamespace="http://ouaf.oracle.com/" elementFormDefault="unqualified">
- <xsd:element name="Fault">
- <xsd:complexType>
- <xsd:all>
<xsd:element name="ResponseStatus" type="xsd:string" />
<xsd:element name="ResponseCode" type="xsd:int" />
<xsd:element name="ResponseText" type="xsd:string" />
- <xsd:element name="ResponseData" minOccurs="0">
- <xsd:complexType>
<xsd:attribute name="parm1" type="xsd:string" />
<xsd:attribute name="parm2" type="xsd:string" />
<xsd:attribute name="parm3" type="xsd:string" />
<xsd:attribute name="parm4" type="xsd:string" />
<xsd:attribute name="parm5" type="xsd:string" />
<xsd:attribute name="parm6" type="xsd:string" />
<xsd:attribute name="parm7" type="xsd:string" />
<xsd:attribute name="parm8" type="xsd:string" />
<xsd:attribute name="parm9" type="xsd:string" />
<xsd:attribute name="text" type="xsd:string" />
<xsd:attribute name="category" type="xsd:string" />
<xsd:attribute name="numParm" type="xsd:int" />
<xsd:attribute name="number" type="xsd:int" />
</xsd:complexType>
</xsd:element>
- <xsd:element name="ServerMessage" minOccurs="0">
- <xsd:complexType>
- <xsd:all>
<xsd:element name="Category" type="xsd:string" />
<xsd:element name="Number" type="xsd:string" />
<xsd:element name="CallSequence" type="xsd:string" />
<xsd:element name="ProgramName" type="xsd:string" />
<xsd:element name="Text" type="xsd:string" />
<xsd:element name="Description" type="xsd:string" />
<xsd:element name="Table" type="xsd:string" />
<xsd:element name="Field" type="xsd:string" />
</xsd:all>
</xsd:complexType>
</xsd:element>
</xsd:all>
</xsd:complexType>
</xsd:element>
- <xsd:simpleType name="money">
<xsd:restriction base="xsd:decimal" />
</xsd:simpleType>
- <xsd:simpleType name="listAction">
- <xsd:restriction base="xsd:token">
<xsd:enumeration value="delete" />
<xsd:enumeration value="add" />
<xsd:enumeration value="update" />
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>
- <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ouaf="http://ouaf.oracle.com/" targetNamespace="http://ouaf.oracle.com/webservices/c1/C1-AccountMail" elementFormDefault="qualified">
<xsd:import namespace="http://ouaf.oracle.com/" />
- <xsd:element name="C1-AccountMail">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="accountId" minOccurs="0">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
<xsd:maxLength value="65536" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
- <xsd:element name="results" minOccurs="0" maxOccurs="unbounded">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="premise" minOccurs="0">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
<xsd:maxLength value="4000" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
- <xsd:element name="premiseInfo" minOccurs="0">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
<xsd:maxLength value="4000" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="action" type="ouaf:listAction" />
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
- <!-- wsdl:message elements describe potential transactions -->
- <!-- request for operation C1-AccountMail -->
- <wsdl:message name="C1-AccountMailRequest">
<wsdl:part name="body" element="tns:C1-AccountMail" />
</wsdl:message>
- <!-- response for operation C1-AccountMail -->
- <wsdl:message name="C1-AccountMailResponse">
<wsdl:part name="body" element="tns:C1-AccountMail" />
</wsdl:message>
- <!-- fault type -->
- <wsdl:message name="Fault">
<wsdl:part name="fault" element="ouaf:Fault" />
</wsdl:message>
- <!-- wsdl:portType describes messages in an operation -->
- <wsdl:portType name="C1-AccountMailPortType">
<wsdl:documentation>C1-AccountMail version 1: Retrieve an Account's Mailing Address</wsdl:documentation>
- <wsdl:operation name="C1-AccountMail">
<wsdl:input message="tns:C1-AccountMailRequest" />
<wsdl:output message="tns:C1-AccountMailResponse" />
<wsdl:fault name="fault" message="tns:Fault" />
</wsdl:operation>
</wsdl:portType>
- <!-- wsdl:binding states a serialization protocol for this service -->
- <wsdl:binding name="C1-AccountMailSoapBinding" type="tns:C1-AccountMailPortType">
<wsp:PolicyReference URI="policy:Wssp1.2-2007-Https-BasicAuth.xml" />
- <!-- leverage off soap:binding document style ###(no wsdl:foo pointing at
the soap binding) -->
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
- <!-- semi-opaque container of network transport details classed by
soap:binding above ### -->
- <wsdl:operation name="C1-AccountMail">
- <!-- again bind to SOAP? ### -->
<soap:operation soapAction="http://10.1.5.86:6500/webservices/C1-AccountMail#C1-AccountMail" />
- <!-- further specify that the messages in the wsdl:operation
"C1-AccountMail" use SOAP? ### -->
- <wsdl:input>
<soap:body use="literal" />
</wsdl:input>
+ <wsdl:output>
<soap:body use="literal" />
</wsdl:output>
- <wsdl:fault name="fault">
<soap:fault name="fault" use="literal" />
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
- <!-- wsdl:service names a new service "C1-AccountMailService" -->
+ <wsdl:service name="C1-AccountMailService">
<wsdl:documentation>C1-AccountMail version 1: Retrieve an Account's Mailing Address</wsdl:documentation>
- <!-- connect it to the binding "C1-AccountMailSoapBinding" above -->
- <wsdl:port name="C1-AccountMailPort" binding="tns:C1-AccountMailSoapBinding">
- <!-- give the binding a network address -->
<soap:address location="http://10.1.5.86:6500/ouaf/webservices/C1-AccountMail" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Second WSDL
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<!-- Published by JAX-WS RI (http://jax-ws.java.net). RI's version is JAX-WS RI 2.3.0-b170407.2038 svn-revision#2eaca54d17a59d265c6fe886b7fd0027836c766c. -->
<wsdl:definitions xmlns:tns="http://ouaf.oracle.com/webservices/c1/C1-AccountMail" xmlns:ouaf="http://ouaf.oracle.com/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wssutil="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" name="C1-AccountMail" targetNamespace="http://ouaf.oracle.com/webservices/c1/C1-AccountMail">
<wsp:UsingPolicy wssutil:Required="true"/>
<wsdl:documentation>C1-AccountMail version 1: Retrieve an Account's Mailing Address</wsdl:documentation>
<wsdl:types>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ouaf="http://ouaf.oracle.com/" targetNamespace="http://ouaf.oracle.com/" elementFormDefault="unqualified">
<xsd:element name="Fault">
<xsd:complexType>
<xsd:all>
<xsd:element name="ResponseStatus" type="xsd:string"/>
<xsd:element name="ResponseCode" type="xsd:int"/>
<xsd:element name="ResponseText" type="xsd:string"/>
<xsd:element name="ResponseData" minOccurs="0">
<xsd:complexType>
<xsd:attribute name="parm1" type="xsd:string"/>
<xsd:attribute name="parm2" type="xsd:string"/>
<xsd:attribute name="parm3" type="xsd:string"/>
<xsd:attribute name="parm4" type="xsd:string"/>
<xsd:attribute name="parm5" type="xsd:string"/>
<xsd:attribute name="parm6" type="xsd:string"/>
<xsd:attribute name="parm7" type="xsd:string"/>
<xsd:attribute name="parm8" type="xsd:string"/>
<xsd:attribute name="parm9" type="xsd:string"/>
<xsd:attribute name="text" type="xsd:string"/>
<xsd:attribute name="category" type="xsd:string"/>
<xsd:attribute name="numParm" type="xsd:int"/>
<xsd:attribute name="number" type="xsd:int"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="ServerMessage" minOccurs="0">
<xsd:complexType>
<xsd:all>
<xsd:element name="Category" type="xsd:string"/>
<xsd:element name="Number" type="xsd:string"/>
<xsd:element name="CallSequence" type="xsd:string"/>
<xsd:element name="ProgramName" type="xsd:string"/>
<xsd:element name="Text" type="xsd:string"/>
<xsd:element name="Description" type="xsd:string"/>
<xsd:element name="Table" type="xsd:string"/>
<xsd:element name="Field" type="xsd:string"/>
</xsd:all>
</xsd:complexType>
</xsd:element>
</xsd:all>
</xsd:complexType>
</xsd:element>
<xsd:simpleType name="money">
<xsd:restriction base="xsd:decimal"/>
</xsd:simpleType>
<xsd:simpleType name="listAction">
<xsd:restriction base="xsd:token">
<xsd:enumeration value="delete"/>
<xsd:enumeration value="add"/>
<xsd:enumeration value="update"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ouaf="http://ouaf.oracle.com/" targetNamespace="http://ouaf.oracle.com/webservices/c1/C1-AccountMail" elementFormDefault="qualified">
<xsd:import namespace="http://ouaf.oracle.com/"/>
<xsd:element name="C1-AccountMail">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="accountId" minOccurs="0">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="65536"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="results" minOccurs="0" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="premise" minOccurs="0">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="4000"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="premiseInfo" minOccurs="0">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="4000"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="action" type="ouaf:listAction"/>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
<!-- wsdl:message elements describe potential transactions -->
<!-- request for operation C1-AccountMail -->
<wsdl:message name="C1-AccountMailRequest">
<wsdl:part name="body" element="tns:C1-AccountMail"/>
</wsdl:message>
<!-- response for operation C1-AccountMail -->
<wsdl:message name="C1-AccountMailResponse">
<wsdl:part name="body" element="tns:C1-AccountMail"/>
</wsdl:message>
<!-- fault type -->
<wsdl:message name="Fault">
<wsdl:part name="fault" element="ouaf:Fault"/>
</wsdl:message>
<!-- wsdl:portType describes messages in an operation -->
<wsdl:portType name="C1-AccountMailPortType">
<wsdl:documentation>C1-AccountMail version 1: Retrieve an Account's Mailing Address</wsdl:documentation>
<wsdl:operation name="C1-AccountMail">
<wsdl:input message="tns:C1-AccountMailRequest"/>
<wsdl:output message="tns:C1-AccountMailResponse"/>
<wsdl:fault name="fault" message="tns:Fault"/>
</wsdl:operation>
</wsdl:portType>
<!-- wsdl:binding states a serialization protocol for this service -->
<wsdl:binding name="C1-AccountMailSoapBinding" type="tns:C1-AccountMailPortType">
<wsp:PolicyReference URI="policy:Wssp1.2-2007-Https-BasicAuth.xml"/>
<!-- leverage off soap:binding document style ###(no wsdl:foo pointing at
the soap binding) -->
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<!-- semi-opaque container of network transport details classed by
soap:binding above ### -->
<wsdl:operation name="C1-AccountMail">
<!-- again bind to SOAP? ### -->
<soap:operation soapAction="http://CIS17/webservices/C1-AccountMail#C1-AccountMail"/>
<!-- further specify that the messages in the wsdl:operation
"C1-AccountMail" use SOAP? ### -->
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
<wsdl:fault name="fault">
<soap:fault name="fault" use="literal"/>
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
<!-- wsdl:service names a new service "C1-AccountMailService" -->
<wsdl:service name="C1-AccountMailService">
<wsdl:documentation>C1-AccountMail version 1: Retrieve an Account's Mailing Address</wsdl:documentation>
<!-- connect it to the binding "C1-AccountMailSoapBinding" above -->
<wsdl:port name="C1-AccountMailPort" binding="tns:C1-AccountMailSoapBinding">
<!-- give the binding a network address -->
<soap:address location="http://10.1.5.95:6500/ouaf/webservices/C1-AccountMail"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
I am trying to create a client to send a SOAP request with spring boot to the wsdl defined bellow:
<?xml version="1.0" encoding="ISO-8859-1"?>
<definitions xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="urn:ATMWebSvr" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="urn:ATMWebSvr">
<types>
<xsd:schema targetNamespace="urn:ATMWebSvr"
>
<xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
<xsd:import namespace="http://schemas.xmlsoap.org/wsdl/" />
<xsd:complexType name="ErroProcesso">
<xsd:sequence>
<xsd:element name="Codigo" type="xsd:string" minOccurs="1" maxOccurs="1"/>
<xsd:element name="Descricao" type="xsd:string" minOccurs="1" maxOccurs="1"/>
<xsd:element name="ValorEsperado" type="xsd:string" minOccurs="0" maxOccurs="1"/>
<xsd:element name="ValorInformado" type="xsd:string" minOccurs="0" maxOccurs="1"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="ErrosProcesso">
<xsd:sequence>
<xsd:element name="Erro" type="tns:ErroProcesso" minOccurs="1" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="DadosSeguro">
<xsd:sequence>
<xsd:element name="NumeroAverbacao" type="xsd:string" minOccurs="1" maxOccurs="1"/>
<xsd:element name="CNPJSeguradora" type="xsd:string" minOccurs="0" maxOccurs="1"/>
<xsd:element name="NomeSeguradora" type="xsd:string" minOccurs="0" maxOccurs="1"/>
<xsd:element name="NumApolice" type="xsd:string" minOccurs="0" maxOccurs="1"/>
<xsd:element name="TpMov" type="xsd:string" minOccurs="0" maxOccurs="1"/>
<xsd:element name="TpDDR" type="xsd:string" minOccurs="0" maxOccurs="1"/>
<xsd:element name="ValorAverbado" type="xsd:string" minOccurs="0" maxOccurs="1"/>
<xsd:element name="RamoAverbado" type="xsd:string" minOccurs="0" maxOccurs="1"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="SuccessProcesso">
<xsd:sequence>
<xsd:element name="dhAverbacao" type="xsd:dateTime" minOccurs="1" maxOccurs="1"/>
<xsd:element name="Protocolo" type="xsd:string" minOccurs="1" maxOccurs="1"/>
<xsd:element name="DadosSeguro" type="tns:DadosSeguro" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="SuccessProcessoMDFe">
<xsd:sequence>
<xsd:element name="dhChancela" type="xsd:dateTime" minOccurs="1" maxOccurs="1"/>
<xsd:element name="Protocolo" type="xsd:string" minOccurs="1" maxOccurs="1"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="InfoProcesso">
<xsd:sequence>
<xsd:element name="Codigo" type="xsd:string" minOccurs="1" maxOccurs="1"/>
<xsd:element name="Descricao" type="xsd:string" minOccurs="1" maxOccurs="1"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="InfosProcesso">
<xsd:sequence>
<xsd:element name="Info" type="tns:InfoProcesso" minOccurs="1" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="Retorno">
<xsd:sequence>
<xsd:element name="Numero" type="xsd:string" minOccurs="1" maxOccurs="1"/>
<xsd:element name="Serie" type="xsd:string" minOccurs="1" maxOccurs="1"/>
<xsd:element name="Filial" type="xsd:string" minOccurs="1" maxOccurs="1"/>
<xsd:element name="CNPJCli" type="xsd:string" minOccurs="0" maxOccurs="1"/>
<xsd:element name="TpDoc" type="xsd:integer" minOccurs="0" maxOccurs="1"/>
<xsd:element name="InfAdic" type="xsd:string" minOccurs="0" maxOccurs="1"/>
<xsd:element name="Erros" type="tns:ErrosProcesso" minOccurs="0" maxOccurs="1"/>
<xsd:element name="Averbado" type="tns:SuccessProcesso" minOccurs="0" maxOccurs="1"/>
<xsd:element name="Infos" type="tns:InfosProcesso" minOccurs="0" maxOccurs="1"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="RetornoMDFe">
<xsd:sequence>
<xsd:element name="Numero" type="xsd:string" minOccurs="1" maxOccurs="1"/>
<xsd:element name="Serie" type="xsd:string" minOccurs="1" maxOccurs="1"/>
<xsd:element name="Filial" type="xsd:string" minOccurs="1" maxOccurs="1"/>
<xsd:element name="Erros" type="tns:ErrosProcesso" minOccurs="0" maxOccurs="1"/>
<xsd:element name="Declarado" type="tns:SuccessProcessoMDFe" minOccurs="0" maxOccurs="1"/>
<xsd:element name="Infos" type="tns:InfosProcesso" minOccurs="0" maxOccurs="1"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
</types>
<message name="averbaCTeRequest">
<part name="usuario" type="xsd:string" />
<part name="senha" type="xsd:string" />
<part name="codatm" type="xsd:string" />
<part name="xmlCTe" type="xsd:string" /></message>
<message name="averbaCTeResponse">
<part name="Response" type="tns:Retorno" /></message>
<message name="averbaNFeRequest">
<part name="usuario" type="xsd:string" />
<part name="senha" type="xsd:string" />
<part name="codatm" type="xsd:string" />
<part name="xmlNFe" type="xsd:string" /></message>
<message name="averbaNFeResponse">
<part name="Response" type="tns:Retorno" /></message>
<message name="declaraMDFeRequest">
<part name="usuario" type="xsd:string" />
<part name="senha" type="xsd:string" />
<part name="codatm" type="xsd:string" />
<part name="xmlMDFe" type="xsd:string" /></message>
<message name="declaraMDFeResponse">
<part name="Response" type="tns:RetornoMDFe" /></message>
<message name="AddBackMailRequest">
<part name="usuario" type="xsd:string" />
<part name="senha" type="xsd:string" />
<part name="codatm" type="xsd:string" />
<part name="aplicacao" type="xsd:string" />
<part name="assunto" type="xsd:string" />
<part name="remetentes" type="xsd:string" />
<part name="destinatarios" type="xsd:string" />
<part name="corpo" type="xsd:string" />
<part name="chave" type="xsd:string" />
<part name="chaveresp" type="xsd:string" /></message>
<message name="AddBackMailResponse">
<part name="return" type="xsd:string" /></message>
<portType name="ATMWebSvrPortType">
<operation name="averbaCTe">
<documentation>Interface de averbação eletrônica AT&M para CTe</documentation>
<input message="tns:averbaCTeRequest"/>
<output message="tns:averbaCTeResponse"/>
</operation>
<operation name="averbaNFe">
<documentation>Interface de averbação eletrônica AT&M para NFe</documentation>
<input message="tns:averbaNFeRequest"/>
<output message="tns:averbaNFeResponse"/>
</operation>
<operation name="declaraMDFe">
<documentation>Interface de declaração do MDFe para AT&M</documentation>
<input message="tns:declaraMDFeRequest"/>
<output message="tns:declaraMDFeResponse"/>
</operation>
<operation name="AddBackMail">
<documentation>Serviço de envio de emails para aplicações automatizadas</documentation>
<input message="tns:AddBackMailRequest"/>
<output message="tns:AddBackMailResponse"/>
</operation>
</portType>
<binding name="ATMWebSvrBinding" type="tns:ATMWebSvrPortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="averbaCTe">
<soap:operation soapAction="urn:ATMWebSvr#averbaCTe" style="rpc"/>
<input><soap:body use="literal" namespace="urn:ATMWebSvr"/></input>
<output><soap:body use="literal" namespace="urn:ATMWebSvr"/></output>
</operation>
<operation name="averbaNFe">
<soap:operation soapAction="urn:ATMWebSvr#averbaNFe" style="rpc"/>
<input><soap:body use="literal" namespace="urn:ATMWebSvr"/></input>
<output><soap:body use="literal" namespace="urn:ATMWebSvr"/></output>
</operation>
<operation name="declaraMDFe">
<soap:operation soapAction="urn:ATMWebSvr#declaraMDFe" style="rpc"/>
<input><soap:body use="literal" namespace="urn:ATMWebSvr"/></input>
<output><soap:body use="literal" namespace="urn:ATMWebSvr"/></output>
</operation>
<operation name="AddBackMail">
<soap:operation soapAction="urn:ATMWebSvr#AddBackMail" style="rpc"/>
<input><soap:body use="literal" namespace="urn:ATMWebSvr"/></input>
<output><soap:body use="literal" namespace="urn:ATMWebSvr"/></output>
</operation>
</binding>
<service name="ATMWebSvr">
<port name="ATMWebSvrPort" binding="tns:ATMWebSvrBinding">
<soap:address location="http://webserver.averba.com.br/20/index.soap"/>
</port>
</service>
</definitions>
The thing is, when I generate the classes using JAXB there is not bean for the request objects (I am trying to use the averbaCTeRequest). Now, using soapUI I can use the service normally, I am just having a hard time to code this in spring boot. Should I not be using objects? Should I be building this message differently? And on top of that, how do I specify the action "averbaCte" on my request?.
#Configuration
public class AtmIntegracaoConfiguration {
#Value("${atm.url}")
private String url;
#Bean
public Jaxb2Marshaller marshaller() {
Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
marshaller.setContextPath("atm.wsdl");
return marshaller;
}
#Bean
public AtmIntegracaoClient atmIntegracaoClient(Jaxb2Marshaller marshaller) {
AtmIntegracaoClient client = new AtmIntegracaoClient();
client.setDefaultUri(url);
client.setMarshaller(marshaller);
client.setUnmarshaller(marshaller);
return client;
}
}
public class AtmIntegracaoClient extends WebServiceGatewaySupport {
private static final Logger log = LoggerFactory.getLogger(AtmIntegracaoClient.class);
#Value("${atm.usuario}")
private String usuario;
#Value("${atm.senha}")
private String senha;
#Value("${atm.codatm}")
private String codatm;
#Value("${atm.url}")
private String url;
public Retorno averbaCte(String cteXmlStr) {
Retorno response = (Retorno) getWebServiceTemplate()
.marshalSendAndReceive("http://homologaws.averba.com.br/20/index.soap", request,
new SoapActionCallback(
"http://localhost:8080/ATMWebSvr/averbaCTe"));
return response;
}
}
Found the solution. The problem was that this SOAP service is RPC style and I am guessing a bit old. The trick for me was instead of using JAXb to use wsimport.
Just run:
wsimport -keep {wsdl url}
It will generate the objects, an interface for the service and a service implementation.
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?
I know this is an old question, but here is my 2 cents.
As you said, this seems a bug in cxf. I got the same error exposing a SOAP service with JBoss, using JAX-WS annotations in source code (my approach is contract-last, I start with an annotated java class and let cxf generate the service with its WSDL).
To overcome the problem, I specified the SOAP binding style as DOCUMENT, and parameters style as WRAPPED.
I used JAX WS annotation on the Service class:
#WebService
#SOAPBinding(
style = SOAPBinding.Style.DOCUMENT,
parameterStyle = SOAPBinding.ParameterStyle.WRAPPED)
public class MySoapService
You can read more details about SOAP bindings here.
Anyway, this changes the structure of XML messages, but cxf will handle all the details for you.
I have a working web service made with Axis1, and I'm migrating it to Jaxws
I'm creating my client classes with wsimport and maven from my working WSDL file.
The problem I have is that I can see my SOAP response message with data in my logger, but the objects aren't populated with this data.
My wsdl looks like this (I posted only 1 service to make it shorter and removed some of the elements, so please ignore if there are some missing like ResultadoProcesamiento):
<wsdl:definitions targetNamespace="http://ws.test" xmlns:apachesoap="http://xml.apache.org/xml-soap"
xmlns:impl="http://ws.test"
xmlns:intf="http://ws.test"
xmlns:tns1="http://pojo.test"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<wsdl:types>
<schema elementFormDefault="qualified" targetNamespace="http://ws.test" xmlns="http://www.w3.org/2001/XMLSchema" >
<import namespace="http://pojo.test"/>
<element name="validarCertificado">
<complexType>
<sequence>
<element name="cert" type="xsd:string"/>
</sequence>
</complexType>
</element>
<element name="validarCertificadoResponse">
<complexType>
<sequence>
<element name="validarCertificadoReturn" type="tns1:MensajeSalida"/>
</sequence>
</complexType>
</element>
</schema>
<schema elementFormDefault="qualified" targetNamespace="http://pojo.test" xmlns="http://www.w3.org/2001/XMLSchema">
<import namespace="http://ws.test"/>
<complexType name="Respuesta">
<sequence>
<element name="excepcion" nillable="true" type="tns1:Excepcion"/>
<element name="resultadoProcesamiento" nillable="true" type="tns1:ResultadoProcesamiento"/>
</sequence>
</complexType>
<complexType name="MensajeSalida">
<sequence>
<element name="peticion" nillable="true" type="xsd:string"/>
<element name="respuesta" nillable="true" type="tns1:Respuesta"/>
<element name="versionMsg" nillable="true" type="xsd:string"/>
</sequence>
</complexType>
</schema>
</wsdl:types>
<wsdl:message name="validarCertificadoRequest">
<wsdl:part element="impl:validarCertificado" name="parameters"/>
</wsdl:message>
<wsdl:message name="validarCertificadoResponse">
<wsdl:part element="impl:validarCertificadoResponse" name="parameters"/>
</wsdl:message>
<wsdl:portType name="WsTest">
<wsdl:operation name="validarCertificado">
<wsdl:input message="impl:validarCertificadoRequest" name="validarCertificadoRequest"/>
<wsdl:output message="impl:validarCertificadoResponse" name="validarCertificadoResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="WsTestSoapBinding" type="impl:WsTest">
<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="validarCertificado">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="validarCertificadoRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="validarCertificadoResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="WsTestService">
</wsdl:service>
</wsdl:definitions>
I forced to create 2 packages because I had some elements with the same name but from different schemas.
First package:
package-info.java
#XmlSchema(namespace = "http://ws.test", elementFormDefault = XmlNsForm.QUALIFIED)
package test.ws;
ValidarCertificadoResponse.java
#XmlAccessorType(XmlAccessType.FIELD)
#XmlType(name = "", propOrder = { "validarCertificadoReturn" })
#XmlRootElement(name = "validarCertificadoResponse")
public class ValidarCertificadoResponse {
#XmlElement(required = true)
protected MensajeSalida validarCertificadoReturn;
Second package:
package-info.java
#XmlSchema(namespace = "http://pojo.test", elementFormDefault = XmlNsForm.QUALIFIED)
package pojo.ws;
MensajeSalida.java
#XmlAccessorType(XmlAccessType.FIELD)
#XmlType(name = "MensajeSalida", propOrder = { "peticion", "respuesta", "versionMsg" })
public class MensajeSalida {
#XmlElement(required = true, nillable = true)
protected String peticion;
#XmlElement(required = true, nillable = true)
protected Respuesta respuesta;
#XmlElement(required = true, nillable = true)
protected String versionMsg;
And my response SOAP message (it includes only some tags):
<soapenv:Body>
<validarCertificadoResponse xmlns="http://ws.test">
<validarCertificadoReturn>
<peticion>value1</peticion>
<respuesta>
datas
<respuesta/>
<resultadoProcesamiento>
more datas
</resultadoProcesamiento>
After executing the client generated by jaxws-maven-plugin:2.3 my ValidarCertificadoResponse has the next attributes:
ValidarCertificadoResponse.java
validarCertificadoReturn
peticion = null;
respuesta = null;
resultadoProcesamiento = null;
Do you find something wrong? I guess there are mistakes in the WSDL or maybe the plugin is not creating the headers properly?
Thanks.
I found a solution to my problem.
If we check the response SOAP message, we can see that there is only named one schema (http://ws.test), so every other element that belongs to the second schema cannot be transformed because jaxws doesn't find a match.
I cannot modify the web service because it isn't mine, so I adapted my wsdl to have only 1 schema. I guess it isn't the cleanest solution but it works.
Here is an example of how to do it:
BEFORE:
<element name="validarCertificadoResponse">
<complexType>
<sequence>
<element name="validarCertificadoReturn" type="tns1:MensajeSalida"/>
</sequence>
</complexType>
</element>
AFTER:
<xsd:element name="validarCertificadoResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="validarCertificadoReturn">
<!-- This is the content of tns1:MensajeSalida -->
<xsd:complexType>
<xsd:sequence>
<xsd:element name="peticion" type="xsd:string"/>
<!-- This is the content of tns1:Respuesta -->
<xsd:element name="respuesta">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="excepcion" nillable="true">
<!-- This is the content of tns1:Excepcion -->
<xsd:complexType>
<xsd:sequence>
<xsd:element name="codigoError" nillable="true" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="resultadoProcesamiento" nillable="true">
<!-- This is the content of tns1:ResultadoProcesamiento -->
<xsd:complexType>
<xsd:sequence>
<xsd:element name="resultado" nillable="true" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="versionMsg" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
I have written a WSDL to generate the Stubs and skeleton but my skeletons are not getting generated in the eclipse. I am using Helios version of Eclipse.
Can any one tell what is the issue with WSDL?
I want to use Axis 2. I tried to generate the skeleton using wsdl2java also but it gives compilation issues in the generated classes. I am not able to attach the file here so I am pasting it here.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions xmlns:impl="http://DefaultNamespace"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:apachesoap="http://xml.apache.org/xml-soap"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
name="Test" targetNamespace="http://DefaultNamespace">
<wsdl:types>
<xsd:schema elementFormDefault="qualified"
targetNamespace="http://DefaultNamespace" xmlns="http://www.w3.org/2001/XMLSchema">
<import namespace="http://xml.apache.org/xml-soap" />
<xsd:element name="serviceMethod">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="vo" type="impl:MyVo" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:complexType name="MyVo">
<xsd:sequence>
<xsd:element name="name" nillable="false" type="xsd:string" />
<xsd:element name="params" nillable="true"
type="apachesoap:Map" />
</xsd:sequence>
</xsd:complexType>
<xsd:element name="serviceMethodResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="serviceMethodReturn" type="impl:MyVo" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<xsd:schema elementFormDefault="qualified"
targetNamespace="http://xml.apache.org/xml-soap" xmlns="http://www.w3.org/2001/XMLSchema">
<import namespace="http://DefaultNamespace" />
<xsd:complexType name="mapItem">
<xsd:sequence>
<xsd:element name="key" nillable="true" type="xsd:anyType" />
<xsd:element name="value" nillable="true" type="xsd:anyType" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="Map">
<xsd:sequence>
<xsd:element maxOccurs="unbounded" minOccurs="0"
name="item" type="apachesoap:mapItem" />
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
</wsdl:types>
<wsdl:message name="serviceMethodRequest">
<wsdl:part element="impl:serviceMethod" name="parameters" />
</wsdl:message>
<wsdl:message name="serviceMethodResponse">
<wsdl:part element="impl:serviceMethodResponse" name="parameters" />
</wsdl:message>
<wsdl:portType name="Test">
<wsdl:operation name="serviceMethod">
<wsdl:input message="impl:serviceMethodRequest" name="serviceMethodRequest" />
<wsdl:output message="impl:serviceMethodResponse" name="serviceMethodResponse" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="TestSOAP" type="impl:Test">
<soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="serviceMethod">
<soap:operation soapAction="http://DefaultNamespace/serviceMethod" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="Test">
<wsdl:port binding="impl:TestSOAP" name="MyWebService">
<soap:address location="http://localhost:8080/Temp/services/MyService" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
That's a problem with your install.
Download and verify axis2 and the axis2 eclipse plugins, make sure you've set up your AXIS2_HOME class paths.
Sometimes it stops working for me too, and then I have to go and reinstall everything. Don't bother making bug reports to Eclipse or Apache, they are always closed as "WORKSFORME".
Steps to produce code from your wsdl:
Create a dynamic web project.
Create your wsdl file.
Right-click on your wsdl file, select Web Services -> Generate Java Bean Skeleton
Click Finish
The Axis2 libraries, facets, and generated code will be added to your project automagically, and there will be no compilation problems.
I had the same problem. I believe maven folder structure is causing it. I created a new project without maven and it worked. Added maven later. Also check source folders at "Java Build Path". If it is missing you will need to add it.
I was facing the same trouble but now it has been solved. The problem is if you have a method that 'THROWS SOME KIND OF EXCEPTION', then it will cause the problem. Hence instead of throwing the error, try using try-catch block statement.