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.
Related
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've made a WSDL file and I intend to create top down web service out of it. Unfortunately, Eclipse throws this error:
"A problem occurred while running the WSDL validator for namespace http://schemas.xmlsoap.org/wsdl/"
I've made some research and it looks like it's happening because of some Eclipse wsdl-validation bug, explained here
Some guy there claims that he fixed this error with patch, and I've applied it, but the error stays and I'm starting to think that there's some problem with my wsdl file itself.
WebService is supposed to take a list(column) of ID's and return a 2-column table data based on those ID's.
Can you help me find out what is wrong with it?
Eclipse Java EE IDE for Web Developers.
Version: Mars.2 Release (4.5.2)
Build id: 20160218-0600
WTP 1.2.1.20150819-2220
Here's WSDL file:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions
targetNamespace="reb.ecm.ws.RebUtilsService"
xmlns="reb.ecm.ws.RebUtilsService"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
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>
<xsd:complexType name='DPList'>
<xsd:element
minOccurs='0'
maxOccurs='unbounded'
name='DP'
type='DP'/>
</xsd:complexType>
<xsd:complexType name='DP'>
<xsd:all>
<xsd:element
minOccurs='0'
maxOccurs='1'
name='DPID'
type='xsd:int'/>
</xsd:all>
</xsd:complexType>
<xsd:complexType name='WSInfoList'>
<xsd:element
minOccurs='0'
maxOccurs='unbounded'
name='WSInfoItem'
type='WSInfoItem'/>
</xsd:complexType>
<xsd:complexType name='WSInfoItem'>
<xsd:all>
<xsd:element
minOccurs='0'
maxOccurs='1'
name='DPID'
type='xsd:int'/>
</xsd:all>
<xsd:all>
<xsd:element
minOccurs='0'
maxOccurs='1'
name='WSID'
type='xsd:int'/>
</xsd:all>
</xsd:complexType>
</wsdl:types>
<wsdl:message name="inMessage">
<wsdl:part name="DPList" type="DPList" />
</wsdl:message>
<wsdl:message name="outMessage">
<wsdl:part name="WSInfoList" type="WSInfoList" />
</wsdl:message>
<wsdl:portType name="RebUtilsServicePortType">
<wsdl:operation name="GetActualWSIDbyDPID" >
<wsdl:input message="inMessage" />
<wsdl:output message="outMessage" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="RebUtilsServiceHTTPBinding"
type="RebUtilsServicePortType">
<wsdlsoap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="GetActualWSIDbyDPID">
<wsdlsoap:operation soapAction=""/>
<wsdl:input>
<wsdlsoap:body use="literal" />
</wsdl:input>
<wsdl:output>
<wsdlsoap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="RebUtilsServicePorts">
<wsdl:port binding="RebUtilsServiceHTTPBinding" name="RebUtilsService">
<wsdlsoap:address
location="http://localhost:9084/RebUtilsService/RebUtilsServicePorts"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
UPDATE: There were no problem with Eclipse. At least patch, mentioned earlier fixed something.
Answer
Your schema is not properly defined. Please see the below image.
Kindly change it to your corrected datatype element which is defined in your schema definitions, Please change in Eclipse WSDL Design view.
Regenerate your client and let know the results.
You should have seperate XSD schema files and should be mapped based on your requirement, that's why it is failing and please have a look into the exploded design view.
General Rule
While creating a SOAP Service, Please define your required input/output XSD schemas
Using schema as in input you need to generate the WSDL file using your IDE/Maven/any build tool.
For easier manipulations/Edits, please choose Eclipse WSDL Editor.
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.
In my WSDL I have an operation
<wsdl:operation name="theMethod">
<wsdl:input message="input1" name="input1"></wsdl:input>
<wsdl:output message="tns:classNumber1" name="classNumber1"></wsdl:output>
</wsdl:operation>
in my xsd, classNumber1 is a complex type and it is a wrapper for another type: classNumber2
<xs:complexType name="classNumber1">
<xs:sequence>
<xs:element minOccurs="0" name="arg0" type="tns:classNumber2"/>
</xs:sequence>
</xs:complexType>
when I generate classes with cxf (I use cxf maven plugin), I expected that theMethod to return a ClassNumber1 but it was a ClassNumber2.
#WebMethod
#ResponseWrapper(localName="classNumber1" , className="com.model.ClassNumber")
public ClassNumber2 theMethod (Input1 input1){
...
}
Is there a way to tell cxf to generate the method with the wrapper CLassNumber1.
Thanks.
I find the solution in this doc, question "How can I switch my generated web service method calls from wrapper style to non wrapper-style (or vice-versa)?"
The solution to keep wrappers with cxf generation is to add a binding file in the pom.xml:
<defaultOptions>
<bindingFiles>
<bindingFile>${basedir}/src/main/resources/bindings.xjb</bindingFile>
</bindingFiles>
<noAddressBinding>true</noAddressBinding>
</defaultOptions>
In the binding file you set enableWrapperStyle to false:
<jaxws:bindings
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns="http://java.sun.com/xml/ns/jaxws"
xmlns:jaxws="http://java.sun.com/xml/ns/jaxws">
<enableWrapperStyle>false</enableWrapperStyle>
</jaxws:bindings>
Based on the information you have provided I have created a basic interface as shown below.
this works as per your expectation.
<xsd:complexType name="input1">
<xsd:sequence>
<xsd:element name="in" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="ClassNumber1">
<xsd:sequence>
<xsd:element minOccurs="0" name="out" type="tns:ClassNumber2" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="ClassNumber2">
<xsd:sequence>
<xsd:element name="out" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
</wsdl:types>
<wsdl:message name="input1">
<wsdl:part element="tns:input1" name="parameters" />
</wsdl:message>
<wsdl:message name="ClassNumber1">
<wsdl:part element="tns:ClassNumber1" name="parameters" />
</wsdl:message>
<wsdl:portType name="NewWSDLFile">
<wsdl:operation name="NewOperation">
<wsdl:input message="tns:input1" />
<wsdl:output message="tns:ClassNumber1" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="NewWSDLFileSOAP" type="tns:NewWSDLFile">
<soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="NewOperation">
<soap:operation soapAction="http://www.example.org/NewWSDLFile/NewOperation" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="NewWSDLFile">
<wsdl:port binding="tns:NewWSDLFileSOAP" name="NewWSDLFileSOAP">
<soap:address location="http://www.example.org/" />
</wsdl:port>
</wsdl:service>
Please check <wsdl:output message="tns:ClassNumber1" />
I believe you have given the wrong in your output information in your
<wsdl:message name="ClassNumber1">
<wsdl:part element="tns:ClassNumber1" name="parameters" />
</wsdl:message>
Hope this helps.
I've been working for a few days on a problem with a WSDL we've defined. We are using wsimport to generate code from the WSDL and then using that to run a service. During WSImport, 2 elements cannot be resolved somehow which throws warnings. Runtime however, these warnings turn into errors and we cannot run our service. How can we get rid of these warnings and therefore errors?
All pointers will be greatly appreciated.
We are using Metro 2.3 and Java 7.
The WSDL is using xsds from the HR-XML specification, but I trimmed them down to display the problem clearer.
wsimport is reporting:
MacBook-Pro-van-Martin:WSDL-problem sunsear$ wsimport -Xnocompile -s generated "file:DummyService.wsdl"
parsing WSDL...
[WARNING] src-resolve: Cannot resolve the name 'hr:Assignment' to a(n) 'element declaration' component.
line 14 of file:xsd/AssignmentRequestElement.xsd
[WARNING] src-resolve: Cannot resolve the name 'hr:HumanResource' to a(n) 'element declaration' component.
line 15 of file:xsd/AssignmentRequestElement.xsd
Generating code...
WSimport is complaining about hr:Assignment and hr:HumanResource which are referenced in the AssignmentRequestElement.xsd:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns="http://personnel.services.com/services/2013-10"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:hr="http://ns.hr-xml.org/2007-04-15"
targetNamespace="http://personnel.services.com/services/2013-10"
elementFormDefault="qualified" version="2013-10">
<xsd:import namespace="http://ns.hr-xml.org/2007-04-15" schemaLocation="HR-XML-2_5/SIDES/Assignment.xsd"/>
<xsd:import namespace="http://ns.hr-xml.org/2007-04-15" schemaLocation="HR-XML-2_5/SIDES/HumanResource.xsd"/>
<xsd:element name="AssignmentRequestElement">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="hr:Assignment"/>
<xsd:element ref="hr:HumanResource" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
HumanResource looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://ns.hr-xml.org/2007-04-15"
targetNamespace="http://ns.hr-xml.org/2007-04-15" elementFormDefault="qualified" version="2007-04-15">
<xsd:complexType name="HumanResourceType">
<xsd:sequence>
<xsd:element name="HumanResourceId" type="xsd:string" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="HumanResource" type="HumanResourceType"/>
</xsd:schema>
Assignment looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns="http://ns.hr-xml.org/2007-04-15" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://ns.hr-xml.org/2007-04-15" elementFormDefault="qualified" version="2007-04-15">
<xsd:complexType name="AssignmentType">
<xsd:sequence>
<xsd:element name="AssignmentId" type="xsd:string" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="Assignment" type="AssignmentType"/>
</xsd:schema>
For completeness, this is the WSDL itself:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:tns="http://personnel.services.com/services/2013-10"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:hr="http://ns.hr-xml.org/2007-04-15" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://personnel.services.com/services/2013-10">
<wsdl:types>
<xsd:schema
elementFormDefault="qualified">
<xsd:import namespace="http://ns.hr-xml.org/2007-04-15"
schemaLocation="xsd/HR-XML-2_5/CPO/Acknowledgement.xsd"/>
<xsd:import namespace="http://personnel.services.com/services/2013-10"
schemaLocation="xsd/AssignmentRequestElement.xsd"/>
</xsd:schema>
</wsdl:types>
<wsdl:message name="AssignmentRequest">
<wsdl:documentation>A generic request of type Assignment (A) or Assignment+HumanResource (A+HR).
</wsdl:documentation>
<wsdl:part name="input" element="tns:AssignmentRequestElement"/>
</wsdl:message>
<wsdl:message name="Response">
<wsdl:documentation>A generic response of type Acknowledgement.</wsdl:documentation>
<wsdl:part name="output" element="hr:Acknowledgement"/>
</wsdl:message>
<wsdl:portType name="DummyService">
<wsdl:operation name="ProcessAssignment">
<wsdl:documentation>ProcessAssignment is used to send details of an Assignment
The request message is an Assignment (A) or
an Assignment+HumanResource (A+HR) message.
</wsdl:documentation>
<wsdl:input message="tns:AssignmentRequest"/>
<wsdl:output message="tns:Response"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="SoapServiceHttpBinding" type="tns:DummyService">
<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="ProcessAssignment">
<wsdlsoap:operation soapAction="https://dummy.personnel.services.com/ws/DummySoapService/ProcessAssignment"
style="document"/>
<wsdl:input>
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="DummySoapService">
<wsdl:port name="DummyServicesEndpoint" binding="tns:SoapServiceHttpBinding">
<wsdlsoap:address location="https://dummy.personnel.services.com/ws/DummySoapService"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
The WSDL and XSDs are correct according to SoapUI and XMLSpy, they validate messages correctly.
The wsdl and xsds can be downloaded here:
https://www.dropbox.com/sh/t8klaoodjfsd772/G2MBGZxLE_
You have assigned 2 different schema-locations to the same namespaces URL. That could be the reason of this error, because now wsimport does not know where to search for hr: objects.
<xsd:import namespace="http://ns.hr-xml.org/2007-04-15" schemaLocation="HR-XML-2_5/SIDES/Assignment.xsd"/>
<xsd:import namespace="http://ns.hr-xml.org/2007-04-15" schemaLocation="HR-XML-2_5/SIDES/HumanResource.xsd"/>
Have a look at this stackoverflow question for solving this problem:
SAXParseException; src-resolve: Cannot resolve the name '...' to a(n) 'type definition' component