我正在使用SOAP& amp;创建Web服务。 WSDL。在创建WSDL之后,我使用eclipse生成“Java bean skeleton”。从生成的存根中,我可以从IOS应用程序调用Web服务。 在Web服务响应中,我将复杂数据类型返回给用户。问题是, 我正在获取复杂类型的唯一响应标记,如下所示。
我的WSDL是,
<?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>
我的请求XML是,
<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>
我收到的以下回复
<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>
问题: 我将上述XML响应作为相同的标记,如monthListItem,taskListItem。
(i.e,) monthBO -> monthListItem -> taskListItem, taskListItem, etc..., monthListItem -> taskListItem, taskListItem, etc..., monthListItem -> taskListItem, taskListItem, etc..., etc...
我可以更改下面的响应。所以我可以从IOS解析这个回复。
(i.e,) monthBO -> monthListItem1 -> taskListItem1, taskListItem2 monthListItem2 -> taskListItem3, taskListItem4 monthListItem3 -> taskListItem5, taskListItem6 etc...
或者是否可以在IOS中解析复杂类型的响应数据?