I am trying to develop a web service with axis2. The problem is that I don't get the parameters passed in the url for an http Binding.
Here is my service.xml :
<parameter name="ServiceClass">my.package.MyClass
</parameter>
<operation name="getUser">
<messageReceiver class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
</operation>
<parameter name="useOriginalwsdl">true</parameter>
Here is my simplified wsdl :
<definitions ...>
<types>
<schema ...>
<complexType name="User">
<sequence>
<element name="id" type="string"/>
<element name="age" type="int"/>
</sequence>
</complexType>
<element name="getUser">
<complexType>
<sequence>
<element name="id" type="xs:string" form="unqualified" />
</sequence>
</complexType>
</element>
<element name="getUserResponse">
<complexType>
<sequence>
<element name="user" nillable="true"
type="user" />
</sequence>
</complexType>
</element>
</schema>
</types>
<message name="getUserRequest">
<part name="parameters" element="getUser" />
</message>
<message name="getUserResponse">
<part name="parameters" element="getUserResponse" />
</message>
<portType name="testPortType">
<operation name="getUser">
<input message="getUserRequest"
Action="urn:getUser" />
<output message="getUserResponse"
Action="urn:getUserResponse" />
</operation>
</portType>
<binding name="testHttpBinding" type="testPortType">
<binding verb="GET" />
<operation name="getUser">
<http:operation location="getUser" />
<input>
<http:urlEncoded />
<input>
<output>
<mime:content type="text/xml" />
</output>
</operation>
</binding>
<service name="test">
<port name="testHttpEndpoint" binding="testHttpBinding">
<address
location="http://localhost:8080/axis2/services/test.testHttpEndpoint/" />
</port>
</service>
</definitions>
and finally my.package.MyClass :
public final class MyClass {
public User getUser(String id) {
//Do something
}
}
When I call the service with the request http://urlToService/getUser?id=test, I enter in getUser(String id) but the id is null.
Does someone know how am I supposed to fix that?
Thank you
In fact I was doing something wrong.
In MyClass, I am not supposed to do :
public User getUser(String id){
}
but
public User getUser(GetUser getUser){
}
as written in the wsdl file.
Related
I have the web service url
http://seguriteca.sir.renfe.es/u35/GDN/Seguriteca2017/Normativa.nsf/DegradadoMercancias
and I want to get the wsdl to obtain the java classes from java.
How can I get the wsdl?
Edited.
I attach my wsdl. I want to know which are the java classes generated from this wsdl
<?xml version="1.0" encoding="UTF-8"?>
<definitions targetNamespace="urn:DefaultNameSpace"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:apachesoap="http://xml.apache.org/xml-soap"
xmlns:impl="urn:DefaultNameSpace" xmlns:intf="urn:DefaultNameSpace"
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>
<schema targetNamespace="urn:DefaultNameSpace"
xmlns="http://www.w3.org/2001/XMLSchema">
<element name="LINEAS" type="xsd:string" />
<element name="TRAMOS" type="xsd:string" />
<element name="CODUSUARIO" type="xsd:string" />
<element name="NOMUSUARIO" type="xsd:string" />
<complexType name="LISTADO">
<sequence>
<element name="RESULTADO" type="xsd:string" />
<element name="MSG" type="xsd:string" />
</sequence>
</complexType>
<element name="LISTADODOCUMENTOSReturn" type="impl:LISTADO" />
</schema>
</wsdl:types>
<message name="LISTADODOCUMENTOSRequest">
<part element="impl:LINEAS" name="LINEAS" />
<part element="impl:TRAMOS" name="TRAMOS" />
<part element="impl:CODUSUARIO" name="CODUSUARIO" />
<part element="impl:NOMUSUARIO" name="NOMUSUARIO" />
</message>
<message name="LISTADODOCUMENTOSResponse">
<part element="impl:LISTADODOCUMENTOSReturn"
name="LISTADODOCUMENTOSReturn" />
</message>
<portType name="DegradadoMercanciasNotes">
<operation name="LISTADODOCUMENTOS">
<input message="impl:LISTADODOCUMENTOSRequest"
name="LISTADODOCUMENTOSRequest" />
<output message="impl:LISTADODOCUMENTOSResponse"
name="LISTADODOCUMENTOSResponse" />
</operation>
</portType>
<binding name="DominoSoapBinding"
type="impl:DegradadoMercanciasNotes">
<wsdlsoap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http" />
<operation name="LISTADODOCUMENTOS">
<wsdlsoap:operation soapAction="" />
<input name="LISTADODOCUMENTOSRequest">
<wsdlsoap:body use="literal" />
</input>
<output name="LISTADODOCUMENTOSResponse">
<wsdlsoap:body use="literal" />
</output>
</operation>
</binding>
<service name="DegradadoMercanciasNotesService">
<port binding="impl:DominoSoapBinding" name="Domino">
<wsdlsoap:address
location="http://seguriteca.sir.renfe.es:80/u35/GDN/Seguriteca2017/Normativa.nsf/DegradadoMercancias?OpenWebService" />
</port>
</service>
</definitions>
It depends on the framework been used for Web Service implementation.
Usually you can find it appending "?wsdl" or ".wsdl" to the web service URL.
So, I would try with http://seguriteca.sir.renfe.es/u35/GDN/Seguriteca2017/Normativa.nsf/DegradadoMercancias?wsdl or http://seguriteca.sir.renfe.es/u35/GDN/Seguriteca2017/Normativa.nsf/DegradadoMercancias.wsdl
I've made a WS server from a WSDL definition (Contract first approach).
I've generated the Java artifacts with wsimport and tested the service.
Now I've got a problem. Some (not all) arguments of an operation requests are unmarshalled as null!
The web service is SOAP based. The wsdl follow the document-literal convention.
So, this is the schema imported by AbstractFDSInfo.wsdl:
<schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://www.example.com/FDSControl"
xmlns:com="http://www.example.com/FDSCommon"
targetNamespace="http://www.example.com/FDSControl"
elementFormDefault="qualified">
<import namespace="http://www.example.com/FDSCommon" schemaLocation="FDSCommon.xsd"/>
<complexType name="PassengerList">
<sequence>
<element ref="com:Passenger" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
</complexType>
<complexType name="FlightInstanceStatusList">
<sequence>
<element type="com:flightInstanceStatus" name="Status" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
</complexType>
<!-- other operation types here -->
<element name="setPassengerBoarded">
<complexType>
<sequence>
<element ref="com:FlightInstanceId"/>
<element type="string" name="Passenger"/>
</sequence>
</complexType>
</element>
<element name="setPassengerBoardedResponse">
<complexType/>
</element>
<element name="passengerBoardingException">
<complexType>
<sequence>
<element type="token" name="Reason"/>
<element type="string" name="Detail"/>
</sequence>
</complexType>
</element>
<!-- Other operation types here --->
And here is the FDSControlAbstract.wsdl:
<?xml version="1.0" encoding="UTF-8"?>
<definitions name="FDSControlAbstract"
xmlns:tns="http://www.example.com/FDSControl.wsdl"
xmlns:con="http://www.example.com/FDSControl"
xmlns:com="http://www.example.com/FDSCommon"
xmlns="http://schemas.xmlsoap.org/wsdl/"
targetNamespace="http://www.example.com/FDSControl.wsdl">
<types>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:import namespace="http://www.example.com/FDSCommon" schemaLocation="FDSCommon.xsd"/>
<xsd:import namespace="http://www.example.com/FDSControl" schemaLocation="FDSControl.xsd"/>
</xsd:schema>
</types>
<message name="setPassengerBoardedRequest">
<part element="con:setPassengerBoarded" name="Params"/>
</message>
<message name="setPassengerBoardedResponse">
<part element="con:setPassengerBoardedResponse" name="Params"/>
</message>
<message name="passengerBoardingException">
<part element="con:passengerBoardingException" name="Params"/>
</message>
<!-- other messages here -->
<portType name="FDSBoardingPortType">
<!-- other operations here -->
<operation name="setPassengerBoarded">
<documentation>
Sets a passenger as boarded. If the passenger is already boarded,
or the flight instance is not in the boarding status, an exception
is returned.
</documentation>
<input message="tns:setPassengerBoardedRequest"/>
<output message="tns:setPassengerBoardedResponse"/>
<fault message="tns:flightInstanceNotFoundException"
name="flightInstanceNotFoundException"/>
<fault message="tns:passengerBoardingException"
name="passengerBoardingException"/>
<fault message="tns:flightStatusException"
name="flightStatusException"/>
</operation>
</portType>
<!-- other port types here -->
</definitions>
Here is the FDSControl.wsdl:
<?xml version="1.0" encoding="UTF-8"?>
<definitions name="FDSControl"
xmlns:tns="http://www.example.com/FDSControl.wsdl"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns="http://schemas.xmlsoap.org/wsdl/"
targetNamespace="http://www.example.com/FDSControl.wsdl"
elementFormDefault="qualified">
<import namespace="http://www.example.com/FDSControl.wsdl" location="FDSControlAbstract.wsdl"/>
<!-- other bindings here-->
<binding name="FDSBoardingSOAP" type="tns:FDSBoardingPortType">
<!-- other operations here -->
<operation name="setPassengerBoarded">
<soap:operation soapAction="http://www.example.com/FDSControl/setPassengerBoarded"/>
<input> <soap:body use="literal"/> </input>
<output> <soap:body use="literal"/> </output>
<fault name="flightInstanceNotFoundException">
<soap:fault name="flightInstanceNotFoundException" use="literal"/>
</fault>
<fault name="passengerBoardingException">
<soap:fault name="passengerBoardingException" use="literal"/>
</fault>
<fault name="flightStatusException">
<soap:fault name="flightStatusException" use="literal"/>
</fault>
</operation>
</binding>
<service name="FDSBoardingSOAPService">
<port name="FDSBoardingPortType" binding="tns:FDSBoardingSOAP">
<soap:address location="http://localhost:7070/fdscontrol"/>
</port>
</service>
</definitions>
Now here is the definition of the java class implementing the web service:
#WebService(name="FDSBoarding",
endpointInterface="it.polito.dp2.FDS.lab4.server.gen.FDSBoardingPortType",
wsdlLocation="META-INF/FDSControl.wsdl",
portName="FDSBoardingPortType",
serviceName="FDSBoardingSOAPService",
targetNamespace="http://www.example.com/FDSControl.wsdl")
})
public class FDSControlImpl implements FDSBoardingPortType {
private FlightManager manager;
public FDSControlImpl(FlightManager manager) {
this.manager = manager;
}
//other methods here
#Override
public SetPassengerBoardedResponse setPassengerBoarded(SetPassengerBoarded params)
throws FlightInstanceNotFoundException_Exception, FlightStatusException_Exception, PassengerBoardingException_Exception {
return manager.setPassengerBoarded(params);
}
}
You can see I kept the parameters wrapped in a single class.
Now the problem is that, whenever I send a request for setPassengerBoarded(), the server returns null as params.getPassenger()
Is there something wrong with my structure/definitions?
I do not have commenting privileges. I would suggest that first test the web service through SOAP UI.
You would then be sure whether the service is working as you expect or some parameters need to change.
If your test is successful then try to set the same parameters in the proxy.
I was compiling two different WSDLs to the same package. I split the generated code in two packages and the problem disappeared, even though now I have duplicate classes and thus I need to convert back and forth between the these...
I have WSDL url like with below format and that seems is correct. After using wsimport in terminal for parse that I get an error:
Run from terminal:
tux-world#alachiq:~/Desktop/Project/java > wsimport -keep -s wsdl/ example.com/wsdl/wsdl.php?wsdl
parsing WSDL...
[ERROR] "Use of SOAP Encoding is not supported.
SOAP extension element on line 59 in example.com/wsdl/wsdl.php?wsdl has use="encoded" "
Failed to parse the WSDL.
WSDL for Parse:
<?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:tsmswsdl" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="urn:tsmswsdl">
<types>
<xsd:schema targetNamespace="urn:tsmswsdl"
>
<xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
<xsd:import namespace="http://schemas.xmlsoap.org/wsdl/" />
<xsd:complexType name="outGetMessages">
<xsd:complexContent>
<xsd:restriction base="SOAP-ENC:Array">
<xsd:attribute ref="SOAP-ENC:arrayType" wsdl:arrayType="xsd:string[]"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
</xsd:schema>
</types>
<message name="GetMessagesRequest">
<part name="user" type="xsd:string" />
<part name="pass" type="xsd:string" />
<part name="idend" type="xsd:int" />
<part name="count_request" type="xsd:int" /></message>
<message name="GetMessagesResponse">
<part name="return" type="tns:outGetMessages" /></message>
<message name="login_checkRequest">
<part name="user" type="xsd:string" />
<part name="pass" type="xsd:string" /></message>
<message name="login_checkResponse">
<part name="return" type="tns:outGetMessages" /></message>
<message name="send_smsRequest">
<part name="user" type="xsd:string" />
<part name="pass" type="xsd:string" />
<part name="sms_number" type="xsd:string" />
<part name="mobile" type="xsd:string" />
<part name="msg" type="xsd:string" />
<part name="send_date" type="xsd:string" /></message>
<message name="send_smsResponse">
<part name="return" type="tns:outGetMessages" /></message>
<portType name="tsmswsdlPortType">
<operation name="GetMessages">
<documentation>Get specific user info</documentation>
<input message="tns:GetMessagesRequest"/>
<output message="tns:GetMessagesResponse"/>
</operation>
<operation name="login_check">
<documentation>Get specific user info</documentation>
<input message="tns:login_checkRequest"/>
<output message="tns:login_checkResponse"/>
</operation>
<operation name="send_sms">
<documentation>Get specific user info</documentation>
<input message="tns:send_smsRequest"/>
<output message="tns:send_smsResponse"/>
</operation>
</portType>
<binding name="tsmswsdlBinding" type="tns:tsmswsdlPortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="GetMessages">
<soap:operation soapAction="urn:tsmswsdl#GetMessages" style="rpc"/>
<input><soap:body use="encoded" namespace="urn:tsmswsdl" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input>
<output><soap:body use="encoded" namespace="urn:tsmswsdl" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></output>
</operation>
<operation name="login_check">
<soap:operation soapAction="urn:tsmswsdl#login_check" style="rpc"/>
<input><soap:body use="encoded" namespace="urn:tsmswsdl" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input>
<output><soap:body use="encoded" namespace="urn:tsmswsdl" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></output>
</operation>
<operation name="send_sms">
<soap:operation soapAction="urn:tsmswsdl#send_sms" style="rpc"/>
<input><soap:body use="encoded" namespace="urn:tsmswsdl" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input>
<output><soap:body use="encoded" namespace="urn:tsmswsdl" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></output>
</operation>
</binding>
<service name="tsmswsdl">
<port name="tsmswsdlPort" binding="tns:tsmswsdlBinding">
<soap:address location="example.com/wsdl/wsdl.php"/>
</port>
</service>
</definitions>
To remove the ambiguity over whether this question has an answer or not, I'm posting the answer from the comments of #Roman Vottner:
Version 2 of JAX-WS does not support rpc/encoded. If you are in control of the web service try changing rpc/encoded to document/literal.
Suggested readings:
link 1
link 2
link 3
link 4
link 5
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?
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"})