How to pass null value to Document Literal SOAP Request - java

Hi,
I am passing the null value for the resourcekey in the SOAP Request as below.
<urn:createNetwork>
<net:resourceIdentityInfo>
<api:resourceKey ></api:resourceKey>
<api:resourceName>TEST2</api:resourceName>
<api:resourceType>NETWORK</api:resourceType>
</net:resourceIdentityInfo>
</urn:createNetwork>
The sample WSDL file for this request is as below:
<wsdl:operation name="createNetwork">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="createNetworkRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="createNetworkResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<element name="createNetwork">
<complexType>
<sequence>
<element name="in0" type="tns5:NetworkInfo"/>
</sequence>
</complexType>
</element>
<element name="createNetworkResponse">
<complexType>
<sequence>
<element name="createNetworkReturn" type="tns2:ResourceIdentityInfo"/>
</sequence>
</complexType>
</element>
<wsdl:message name="createNetworkRequest">
<wsdl:part element="intf:createNetwork" name="parameters">
</wsdl:part>
</wsdl:message>
<complexType name="NetworkInfo">
<sequence>
<element name="comments" nillable="true" type="impl:ArrayOf_xsd_anyType"/>
<element name="description" nillable="true" type="xsd:string"/>
<element name="dnsDomainName" nillable="true" type="xsd:string"/>
<element name="documentUrls" nillable="true" type="impl:ArrayOf_xsd_anyType"/>
<element name="resourceIdentityInfo" nillable="true" type="tns2:ResourceIdentityInfo"/>
</sequence>
</complexType>
<complexType name="ResourceIdentityInfo">
<sequence>
<element name="resourceKey" nillable="true" type="xsd:string"/>
<element name="resourceName" nillable="true" type="xsd:string"/>
<element name="resourceType" nillable="true" type="xsd:string"/>
</sequence>
</complexType>
I have declared as nillable=true in all the places.
If i pass the resourcekey as empty, in SOAP UI I am getting null pointer exception.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<soapenv:Fault>
<faultcode>soapenv:Server.userException</faultcode>
<faultstring>java.lang.NullPointerException</faultstring>
<detail>
<ns1:hostname xmlns:ns1="http://xml.apache.org/axis/">linbgg244.lss.emc.com</ns1:hostname>
</detail>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
I have tried with
<api:resourceKey xsi:nil="true" ></api:resourceKey>
The same null pointer exception is getting.
Could you please guide to resolve the issue?
Thanks in advance.

I don't think you have to pass null here. AFAIK, the webservice code is throwing the NullPointerException during processing of the SOAP request. Try to identify why is that ? and do a null check or make changes in the logic to prevent it.

Related

Cannot resolve the name ... to a(n) 'type definition' component

I want to import code from a WSDL file with wsimport, but i receiving this error below.
[WARNING] src-resolve: Cannot resolve the name 'impl:ArrayOf_tns1_IndicadorVO' to a(n) 'type definition' component.
Here's the WSDL file...
<?xml version="1.0" encoding="UTF-8"?> <wsdl:definitions targetNamespace="http://ws.cnmpind.cnmp.gov.br" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://ws.cnmpind.cnmp.gov.br" xmlns:intf="http://ws.cnmpind.cnmp.gov.br" xmlns:tns1="http://vo.ws.cnmpind.cnmp.gov.br" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!--WSDL created by Apache Axis version: 1.4
Built on Apr 22, 2006 (06:55:48 PDT)-->
<wsdl:types>
<schema elementFormDefault="qualified" targetNamespace="http://ws.cnmpind.cnmp.gov.br" xmlns="http://www.w3.org/2001/XMLSchema">
<import namespace="http://vo.ws.cnmpind.cnmp.gov.br"/>
<element name="getQuestionariosDisponiveis">
<complexType>
<sequence>
<element name="email" type="xsd:string"/>
<element name="senha" type="xsd:string"/>
<element name="dataInicio" type="xsd:string"/>
<element name="dataFinal" type="xsd:string"/>
<element name="areaAtuacao" type="xsd:string"/>
</sequence>
</complexType>
</element>
<element name="getQuestionariosDisponiveisResponse">
<complexType>
<sequence>
<element maxOccurs="unbounded" name="getQuestionariosDisponiveisReturn" type="tns1:QuestionarioVO"/>
</sequence>
</complexType>
</element>
<complexType name="ArrayOf_tns1_IndicadorVO">
<sequence>
<element maxOccurs="unbounded" minOccurs="0" name="item" type="tns1:IndicadorVO"/>
</sequence>
</complexType>
<element name="salvaRespostasQuestionarios">
<complexType>
<sequence>
<element name="email" type="xsd:string"/>
<element name="senha" type="xsd:string"/>
<element name="dataInicio" type="xsd:string"/>
<element name="dataFinal" type="xsd:string"/>
<element name="areaAtuacao" type="xsd:string"/>
<element maxOccurs="unbounded" name="questionarios" type="tns1:QuestionarioVO"/>
</sequence>
</complexType>
</element>
<element name="salvaRespostasQuestionariosResponse">
<complexType/>
</element>
</schema>
<schema elementFormDefault="qualified" targetNamespace="http://vo.ws.cnmpind.cnmp.gov.br" xmlns="http://www.w3.org/2001/XMLSchema">
<import namespace="http://ws.cnmpind.cnmp.gov.br"/>
<complexType name="IndicadorVO">
<sequence>
<element name="descricaoDescritor" nillable="true" type="xsd:string"/>
<element name="id" type="xsd:long"/>
<element name="idDescritor" type="xsd:int"/>
<element name="idIndicadorPai" type="xsd:long"/>
<element name="idQuestionario" type="xsd:long"/>
<element name="nomeDescritor" nillable="true" type="xsd:string"/>
<element name="ordem" type="xsd:int"/>
<element name="tamanhoDescritor" nillable="true" type="xsd:decimal"/>
<element name="tipoDescritor" nillable="true" type="xsd:string"/>
<element name="valor" nillable="true" type="xsd:decimal"/>
</sequence>
</complexType>
<complexType name="QuestionarioVO">
<sequence>
<element name="aberto" type="xsd:boolean"/>
<element name="dataAtualizacao" nillable="true" type="xsd:string"/>
<element name="dataInicio" nillable="true" type="xsd:string"/>
<element name="dataTermino" nillable="true" type="xsd:string"/>
<element name="descricaoArea" nillable="true" type="xsd:string"/>
<element name="id" type="xsd:long"/>
<element name="idArea" type="xsd:int"/>
<element name="idUnidade" type="xsd:int"/>
<element name="indicadores" nillable="true" type="impl:ArrayOf_tns1_IndicadorVO"/>
<element name="nomeArea" nillable="true" type="xsd:string"/>
<element name="nomeUnidade" nillable="true" type="xsd:string"/>
<element name="nomeUsuarioAtualizacao" nillable="true" type="xsd:string"/>
<element name="siglaUnidade" nillable="true" type="xsd:string"/>
</sequence>
</complexType>
</schema>
</wsdl:types>
<wsdl:message name="salvaRespostasQuestionariosResponse">
<wsdl:part element="impl:salvaRespostasQuestionariosResponse" name="parameters"/>
</wsdl:message>
<wsdl:message name="getQuestionariosDisponiveisResponse">
<wsdl:part element="impl:getQuestionariosDisponiveisResponse" name="parameters"/>
</wsdl:message>
<wsdl:message name="getQuestionariosDisponiveisRequest">
<wsdl:part element="impl:getQuestionariosDisponiveis" name="parameters"/>
</wsdl:message>
<wsdl:message name="salvaRespostasQuestionariosRequest">
<wsdl:part element="impl:salvaRespostasQuestionarios" name="parameters"/>
</wsdl:message>
<wsdl:portType name="QuestionarioWS">
<wsdl:operation name="getQuestionariosDisponiveis">
<wsdl:input message="impl:getQuestionariosDisponiveisRequest" name="getQuestionariosDisponiveisRequest"/>
<wsdl:output message="impl:getQuestionariosDisponiveisResponse" name="getQuestionariosDisponiveisResponse"/>
</wsdl:operation>
<wsdl:operation name="salvaRespostasQuestionarios">
<wsdl:input message="impl:salvaRespostasQuestionariosRequest" name="salvaRespostasQuestionariosRequest"/>
<wsdl:output message="impl:salvaRespostasQuestionariosResponse" name="salvaRespostasQuestionariosResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="QuestionarioWSSoapBinding" type="impl:QuestionarioWS">
<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="getQuestionariosDisponiveis">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="getQuestionariosDisponiveisRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="getQuestionariosDisponiveisResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="salvaRespostasQuestionarios">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="salvaRespostasQuestionariosRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="salvaRespostasQuestionariosResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="QuestionarioWSService">
<wsdl:port binding="impl:QuestionarioWSSoapBinding" name="QuestionarioWS">
<wsdlsoap:address location="http://aplicativos.cnmp.gov.br/cnmpind/services/QuestionarioWS"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Someone can give me some light? Thanks!
EDIT 1:
This is just a warning. The true error is
package-info.java:1: error: error while writing package-info: could
not create parent directories
#javax.xml.bind.annotation.XmlSchema(namespace =
"http://ws.cnmpind.cnmp.gov.br", elementFormDefault =
javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
So, the code was generated, but the error happens when compiling.
Its seems to be a WSIMPORT bug, i don't know.
To solve the problem, I used the param "-Xnocompile" to force WSIMPORT only generate the code whithout compiling.
After that, i compiled the code by command line with javac and put the classes into a .jar
I added the .jar to the project and everything are running fine.

How to fix wsdl file errors?

Dears
I trying to make and create web service, firstly i created the server side and wsdl file, but i get some errors in this wsdl file and i tried many time to solve it, i guess i should check the xmlns or xsd.
actually i'am new in webwervices and don't now exactly how to investigate them, please advise me and let me know the error in my code.
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://DefaultNamespace"
xmlns:apachesoap="http://xml.apache.org/xml-soap"
xmlns:impl="http://DefaultNamespace"
xmlns:intf="http://DefaultNamespace"
xmlns:tns1="http://swing.javax"
xmlns:tns2="http://awt.java"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!--WSDL created by Apache Axis version: 1.4
Built on Apr 22, 2006 (06:55:48 PDT)-->
<wsdl:types>
<schema elementFormDefault="qualified"
targetNamespace="http://DefaultNamespace"
xmlns="http://www.w3.org/2001/XMLSchema">
<import namespace="http://awt.java"/>
<import namespace="http://swing.javax"/>
The errors is
Description Resource Path Location Type
src-resolve: Cannot resolve the name 'tns1:JPasswordField' to a(n) 'type definition' component. ImbCal.wsdl /SSPtest/WebContent/wsdl line 196 WSDL Problem
Description Resource Path Location Type
src-resolve: Cannot resolve the name 'tns2:List' to a(n) 'type definition' component. ImbCal.wsdl /SSPtest/WebContent/wsdl line 171 WSDL Problem
Description Resource Path Location Type
schema_reference.4: Failed to read schema document 'null', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not . ImbCal.wsdl /SSPtest/WebContent/wsdl line 7 WSDL Problem
Description Resource Path Location Type
schema_reference.4: Failed to read schema document 'null', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not . ImbCal.wsdl /SSPtest/WebContent/wsdl line 8 WSDL Problem
here one of elements
<element name="dbSelect">
<complexType>
<sequence>
<element name="sql" type="xsd:string"/>
<element name="level" type="xsd:string"/>
<element name="mat_sel2" type="tns2:List"/>
<element name="mymaterial" type="tns2:List"/>
</sequence>
</complexType>
</element>
This is the full code, i just edit the wrong from the code and regenerate the wsdll.
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://DefaultNamespace"
xmlns:apachesoap="http://xml.apache.org/xml-soap"
xmlns:impl="http://DefaultNamespace"
xmlns:intf="http://DefaultNamespace"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!--WSDL created by Apache Axis version: 1.4
Built on Apr 22, 2006 (06:55:48 PDT)-->
<wsdl:types>
<schema elementFormDefault="qualified"
targetNamespace="http://DefaultNamespace" xmlns="http://www.w3.org
/2001/XMLSchema">
<element name="main">
<complexType>
<sequence>
<element maxOccurs="unbounded" name="arg" type="xsd:string"/>
</sequence>
</complexType>
</element>
<element name="mainResponse">
<complexType>
<sequence>
<element maxOccurs="unbounded" name="mainReturn" type="xsd:string"/>
</sequence>
</complexType>
</element>
<element name="finalmaterial">
<complexType>
<sequence>
<element name="Couresn" type="xsd:string"/>
<element name="IDL" type="xsd:string"/>
<element name="Myco2" type="xsd:string"/>
<element name="userlevel" type="xsd:int"/>
<element name="LevelL" type="xsd:string"/>
</sequence>
</complexType>
</element>
<element name="finalmaterialResponse">
<complexType>
<sequence>
<element maxOccurs="unbounded" name="finalmaterialReturn"
type="xsd:string"/>
</sequence>
</complexType>
</element>
</schema>
</wsdl:types>
<wsdl:message name="finalmaterialRequest">
<wsdl:part element="impl:finalmaterial" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:message name="finalmaterialResponse">
<wsdl:part element="impl:finalmaterialResponse" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:message name="mainRequest">
<wsdl:part element="impl:main" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:message name="mainResponse">
<wsdl:part element="impl:mainResponse" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:portType name="ImbCal">
<wsdl:operation name="main">
<wsdl:input message="impl:mainRequest" name="mainRequest">
</wsdl:input>
<wsdl:output message="impl:mainResponse" name="mainResponse">
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="finalmaterial">
<wsdl:input message="impl:finalmaterialRequest"
name="finalmaterialRequest">
</wsdl:input>
<wsdl:output message="impl:finalmaterialResponse"
name="finalmaterialResponse">
</wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="ImbCalSoapBinding" type="impl:ImbCal">
<wsdlsoap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="main">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="mainRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="mainResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="finalmaterial">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="finalmaterialRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="finalmaterialResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="ImbCalService">
<wsdl:port binding="impl:ImbCalSoapBinding" name="ImbCal">
<wsdlsoap:address location="http://localhost:8080/SSPwebservice
/services/ImbCal"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

Jaxws doesn't populate results

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>

SOAP - response XML unique tag

I am creating the web-service with the use of SOAP & WSDL. After creating WSDL I am generating the "Java bean skeleton" using eclipse. From the generated stubs I can able to call the web-service from IOS app.
In the web-service response I am returning the complex data type to the user. The problem is,
I am getting the unique response tag for the complex type as given below.
My WSDL is,
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://service.cmp.app.com" xmlns:intf="http://service.cmp.app.com" xmlns:tns1="http://request.cmp.app.com" xmlns:tns2="http://response.cmp.app.com" xmlns:tns3="http://bean.cmp.app.com" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://service.cmp.app.com">
<!--WSDL created by Apache Axis version: 1.4 Built on Apr 22, 2006 (06:55:48
PDT) -->
<wsdl:types>
<schema xmlns="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://service.cmp.app.com">
<import namespace="http://response.cmp.app.com"/>
<import namespace="http://request.cmp.app.com"/>
<import namespace="http://bean.cmp.app.com"/>
<element name="ViewAppTrack">
<complexType>
<sequence>
<element name="ViewAppTrackRequest" type="tns1:ViewAppTrackRequest"/>
</sequence>
</complexType>
</element>
<element name="ViewAppTrackResponse">
<complexType>
<sequence>
<element name="ViewAppTrackResponseReturn" type="tns2:ViewAppTrackResponse"/>
</sequence>
</complexType>
</element>
<complexType name="ArrayOf_tns3_MonthListBO">
<sequence>
<element maxOccurs="unbounded" minOccurs="0" name="monthListItem" type="tns3:MonthListBO"/>
</sequence>
</complexType>
<complexType name="ArrayOf_tns3_TaskListBO">
<sequence>
<element maxOccurs="unbounded" minOccurs="0" name="taskListItem" type="tns3:TaskListBO"/>
</sequence>
</complexType>
</schema>
<schema xmlns="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://request.cmp.app.com">
<import namespace="http://response.cmp.app.com"/>
<import namespace="http://service.cmp.app.com"/>
<import namespace="http://bean.cmp.app.com"/>
<complexType name="ViewAppTrackRequest">
<sequence>
<element name="userId" nillable="true" type="xsd:string"/>
</sequence>
</complexType>
</schema>
<schema xmlns="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://bean.cmp.app.com">
<import namespace="http://response.cmp.app.com"/>
<import namespace="http://service.cmp.app.com"/>
<import namespace="http://request.cmp.app.com"/>
<complexType name="MonthListBO">
<sequence>
<element name="date" nillable="true" type="xsd:string"/>
<element name="lockStatus" nillable="true" type="xsd:string"/>
<element name="dailyTime" nillable="true" type="xsd:string"/>
<element name="taskListNew" nillable="true" type="impl:ArrayOf_tns3_TaskListBO"/>
</sequence>
</complexType>
<complexType name="TaskListBO">
<sequence>
<element name="trackId" type="xsd:int"/>
<element name="taskId" type="xsd:int"/>
<element name="trackDate" nillable="true" type="xsd:string"/>
</sequence>
</complexType>
</schema>
<schema xmlns="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://response.cmp.app.com">
<import namespace="http://service.cmp.app.com"/>
<import namespace="http://request.cmp.app.com"/>
<import namespace="http://bean.cmp.app.com"/>
<complexType name="ViewAppTrackResponse">
<sequence>
<element name="monthBO" nillable="true" type="impl:ArrayOf_tns3_MonthListBO"/>
<element name="userId" nillable="true" type="xsd:string"/>
<element name="projectId" nillable="true" type="xsd:string"/>
<element name="customerId" nillable="true" type="xsd:string"/>
</sequence>
</complexType>
</schema>
</wsdl:types>
<wsdl:message name="ViewAppTrackRequest">
<wsdl:part element="impl:ViewAppTrack" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:message name="ViewAppTrackResponse">
<wsdl:part element="impl:ViewAppTrackResponse" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:portType name="AppWeb">
<wsdl:operation name="ViewAppTrack">
<wsdl:input message="impl:ViewAppTrackRequest" name="ViewAppTrackRequest">
</wsdl:input>
<wsdl:output message="impl:ViewAppTrackResponse" name="ViewAppTrackResponse">
</wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="AppWebSoapBinding" type="impl:AppWeb">
<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="ViewAppTrack">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="ViewAppTrackRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="ViewAppTrackResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="AppWebService">
<wsdl:port binding="impl:AppWebSoapBinding" name="AppWeb">
<wsdlsoap:address location="http://localhost:8080/test/services/AppWeb"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
And my request XML is,
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://service.cmp.app.com" xmlns:req="http://request.cpm.app.com">
<soapenv:Header/>
<soapenv:Body>
<ser:ViewAppTrack>
<ser:ViewAppTrackRequest>
<req:userId>5</req:userId>
</ser:ViewAppTrackRequest>
</ser:ViewAppTrack>
</soapenv:Body>
</soapenv:Envelope>
The following response I am getting,
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<ViewAppTrackResponse xmlns="http://service.cmp.app.com">
<ViewAppTrackResponseReturn>
<ns1:monthBO xmlns:ns1="http://response.cmp.app.com">
<monthListItem>
<ns2:date xmlns:ns2="http://bean.cmp.app.com">1-2-2014, Saturday (nonworking day)</ns2:date>
<ns3:lockStatus xmlns:ns3="http://bean.cmp.app.com">N</ns3:lockStatus>
<ns4:dailyTime xsi:nil="true" xmlns:ns4="http://bean.cmp.app.com"/>
<ns5:taskListNew xsi:nil="true" xmlns:ns5="http://bean.cmp.app.com"/>
</monthListItem>
<monthListItem>
<ns6:date xmlns:ns6="http://bean.cmp.app.com">2-2-2014, Sunday (nonworking day)</ns6:date>
<ns7:lockStatus xmlns:ns7="http://bean.cmp.app.com">N</ns7:lockStatus>
<ns8:dailyTime xmlns:ns8="http://bean.cmp.app.com">04:00</ns8:dailyTime>
<ns9:taskListNew xmlns:ns9="http://bean.cmp.app.com">
<taskListItem>
<ns9:trackId>1070</ns9:trackId>
<ns9:taskId>14</ns9:taskId>
</taskListItem>
<taskListItem>
<ns9:trackId>1094</ns9:trackId>
<ns9:taskId>44</ns9:taskId>
</taskListItem>
</ns9:taskListNew>
</monthListItem>
<monthListItem>
<ns10:date xmlns:ns10="http://bean.cmp.app.com">3-2-2014, Monday</ns10:date>
<ns11:lockStatus xmlns:ns11="http://bean.cmp.app.com">N</ns11:lockStatus>
<ns12:dailyTime xmlns:ns12="http://bean.cmp.app.com">08:00</ns12:dailyTime>
<ns13:taskListNew xmlns:ns13="http://bean.cmp.app.com">
<taskListItem>
<ns13:trackId>1071</ns13:trackId>
<ns13:taskId>14</ns13:taskId>
</taskListItem>
<taskListItem>
<ns13:trackId>1073</ns13:trackId>
<ns13:taskId>44</ns13:taskId>
</taskListItem>
</ns13:taskListNew>
</monthListItem>
</ns1:monthBO>
<ns14:userId xsi:nil="true" xmlns:ns114="http://response.cmp.app.com"/>5</ns14:userId>
</ViewAppTrackResponseReturn>
</ViewAppTrackResponse>
</soapenv:Body>
</soapenv:Envelope>
The problem:
I am getting the above XML response as same tag like monthListItem, taskListItem.
(i.e,) monthBO ->
monthListItem -> taskListItem, taskListItem, etc...,
monthListItem -> taskListItem, taskListItem, etc...,
monthListItem -> taskListItem, taskListItem, etc...,
etc...
Can I change the response like below. So that I can parse this response from IOS.
(i.e,) monthBO ->
monthListItem1 -> taskListItem1, taskListItem2
monthListItem2 -> taskListItem3, taskListItem4
monthListItem3 -> taskListItem5, taskListItem6
etc...
Or is it possible to parse the complex type response data in IOS?

Specify order of elements in a SOAP response using java

I have a web service that returns a dataset object that contains the current weather forecast along with 0 or more weather alerts for a county/state. The dataset object just contains a Weather object and an array of Alerts objects. One of the clients of this would like to have it so the response gives the weather first instead of the alerts. Is there a way to specify the order of the response elements? I thought I could just change the WSDL to map out the weather first then the alerts, but that didn't do anything.
Here's the generic WSDL sheet:
(well, it showed formatted in the preview but not after posting... how can I post formatted XML on here? I tried using back-ticks as well as pre and code).
<wsdl:definitions ...>
<wsdl:types>
<schema elementFormDefault="qualified" targetNamespace="http://ws.sample.com" xmlns="http://www.w3.org/2001/XMLSchema">
<import namespace="http://objects.sample.com"/>
<element name="getAll">
<complexType>
<sequence>
<element name="county" type="xsd:string"/>
<element name="state" type="xsd:string"/>
<element name="latitude" type="xsd:double"/>
<element name="longitude" type="xsd:double"/>
</sequence>
</complexType>
</element>
<element name="getAllResponse">
<complexType>
<sequence>
<element name="getAllReturn" type="tns1:DataSet"/>
</sequence>
</complexType>
</element>
<complexType name="ArrayOf_tns1_Alert">
<sequence>
<element maxOccurs="unbounded" minOccurs="0" name="item" type="tns1:Alert"/>
</sequence>
</complexType>
</schema>
<schema elementFormDefault="qualified" targetNamespace="http://objects.sample.com" xmlns="http://www.w3.org/2001/XMLSchema">
<import namespace="http://ws.sample.com"/>
<complexType name="Alert">
<sequence>
<element name="county" nillable="true" type="xsd:string"/>
<element name="endDate" nillable="true" type="xsd:dateTime"/>
<element name="locationCode" nillable="true" type="xsd:string"/>
<element name="startDate" nillable="true" type="xsd:dateTime"/>
<element name="state" nillable="true" type="xsd:string"/>
<element name="title" nillable="true" type="xsd:string"/>
<element name="warning" nillable="true" type="xsd:string"/>
</sequence>
</complexType>
<complexType name="Weather">
<sequence>
<element name="chancePrecipitation" type="xsd:int"/>
<element name="period" nillable="true" type="xsd:string"/>
<element name="skyConditions" nillable="true" type="xsd:string"/>
<element name="temperature" type="xsd:int"/>
<element name="temperatureType" nillable="true" type="xsd:string"/>
<element name="temperatureUnit" nillable="true" type="xsd:string"/>
<element name="windDirection" nillable="true" type="xsd:string"/>
<element name="windSpeed" type="xsd:int"/>
<element name="windUnit" nillable="true" type="xsd:string"/>
</sequence>
</complexType>
<complexType name="DataSet">
<sequence>
<element name="weather" nillable="true" type="tns1:Weather"/>
<element name="alert" nillable="true" type="impl:ArrayOf_tns1_Alert"/>
</sequence>
</complexType>
</schema>
</wsdl:types>
<wsdl:message name="getAllResponse">
<wsdl:part element="impl:getAllResponse" name="parameters"/>
</wsdl:message>
<wsdl:message name="getAllRequest">
<wsdl:part element="impl:getAll" name="parameters"/>
</wsdl:message>
<wsdl:portType name="TSTWeather">
<wsdl:operation name="getAll">
<wsdl:input message="impl:getAllRequest" name="getAllRequest"/>
<wsdl:output message="impl:getAllResponse" name="getAllResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="TSTWeatherSoapBinding" type="impl:TSTWeather">
<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="getAll">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="getAllRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="getAllResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="TSTWeatherService">
<wsdl:port binding="impl:TSTWeatherSoapBinding" name="TSTWeather">
<wsdlsoap:address location="http://localhost:8282/Services/service/TSTWeather"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
I don't see how I could specify the order of my service response.
In many cases, just changing the WSDL does not change the service, and it's the service that determines the order of the elements in the XML.
We can change the order by adding JAXB annotations in the particular java file.
For example: #XmlType(propOrder = {"x", "y", "z"})

Categories