每次我得到port.op()
的空响应时,我不知道如何读取ArrayOfNameValuePair
的项目
my Java function
private static ArrayOfNameValuePair op() {
pocodm.obtenerprovincia.ObtenerProvincia service = new pocodm.obtenerprovincia.ObtenerProvincia();
pocodm.obtenerprovincia.ObtenerProvinciaPortType port = service.getObtenerProvinciaSoap();
return port.op();
}
信封
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:obt="http://POCODM/ObtenerProvincia.tws">
<soapenv:Header/>
<soapenv:Body>
<obt:op/>
</soapenv:Body>
</soapenv:Envelope>
反应<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<opResponse xmlns="http://POCODM/ObtenerProvincia.tws">
<results>
<item>
<ns0:name xmlns:ns0="http://ectest556ws1:9081/schema/">AZUAY</ns0:name>
<ns0:value xmlns:ns0="http://ectest556ws1:9081/schema/">01</ns0:value>
</item>
<item>
<ns0:name xmlns:ns0="http://ectest556ws1:9081/schema/">BOLIVAR</ns0:name>
<ns0:value xmlns:ns0="http://ectest556ws1:9081/schema/">02</ns0:value>
</item>
<item>
<ns0:name xmlns:ns0="http://ectest556ws1:9081/schema/">CARCHI</ns0:name>
<ns0:value xmlns:ns0="http://ectest556ws1:9081/schema/">04</ns0:value>
</item>
<item>
<ns0:name xmlns:ns0="http://ectest556ws1:9081/schema/">CAÑAR</ns0:name>
<ns0:value xmlns:ns0="http://ectest556ws1:9081/schema/">03</ns0:value>
</item>
<item>
<ns0:name xmlns:ns0="http://ectest556ws1:9081/schema/">CHIMBORAZO</ns0:name>
<ns0:value xmlns:ns0="http://ectest556ws1:9081/schema/">06</ns0:value>
</item>
<item>
<ns0:name xmlns:ns0="http://ectest556ws1:9081/schema/">COTOPAXI</ns0:name>
<ns0:value xmlns:ns0="http://ectest556ws1:9081/schema/">05</ns0:value>
</item>
<item>
<ns0:name xmlns:ns0="http://ectest556ws1:9081/schema/">EL ORO</ns0:name>
<ns0:value xmlns:ns0="http://ectest556ws1:9081/schema/">07</ns0:value>
</item>
<item>
<ns0:name xmlns:ns0="http://ectest556ws1:9081/schema/">ESMERALDAS</ns0:name>
<ns0:value xmlns:ns0="http://ectest556ws1:9081/schema/">08</ns0:value>
</item>
<item>
<ns0:name xmlns:ns0="http://ectest556ws1:9081/schema/">GALAPAGOS</ns0:name>
<ns0:value xmlns:ns0="http://ectest556ws1:9081/schema/">20</ns0:value>
</item>
<item>
<ns0:name xmlns:ns0="http://ectest556ws1:9081/schema/">GUAYAS</ns0:name>
<ns0:value xmlns:ns0="http://ectest556ws1:9081/schema/">09</ns0:value>
</item>
<item>
<ns0:name xmlns:ns0="http://ectest556ws1:9081/schema/">IMBABURA</ns0:name>
<ns0:value xmlns:ns0="http://ectest556ws1:9081/schema/">10</ns0:value>
</item>
<item>
<ns0:name xmlns:ns0="http://ectest556ws1:9081/schema/">LOJA</ns0:name>
<ns0:value xmlns:ns0="http://ectest556ws1:9081/schema/">11</ns0:value>
</item>
<item>
<ns0:name xmlns:ns0="http://ectest556ws1:9081/schema/">LOS RIOS</ns0:name>
<ns0:value xmlns:ns0="http://ectest556ws1:9081/schema/">12</ns0:value>
</item>
<item>
<ns0:name xmlns:ns0="http://ectest556ws1:9081/schema/">MANABI</ns0:name>
<ns0:value xmlns:ns0="http://ectest556ws1:9081/schema/">13</ns0:value>
</item>
<item>
<ns0:name xmlns:ns0="http://ectest556ws1:9081/schema/">MORONA SANTIAGO</ns0:name>
<ns0:value xmlns:ns0="http://ectest556ws1:9081/schema/">14</ns0:value>
</item>
<item>
<ns0:name xmlns:ns0="http://ectest556ws1:9081/schema/">NAPO</ns0:name>
<ns0:value xmlns:ns0="http://ectest556ws1:9081/schema/">15</ns0:value>
</item>
<item>
<ns0:name xmlns:ns0="http://ectest556ws1:9081/schema/">ORELLANA</ns0:name>
<ns0:value xmlns:ns0="http://ectest556ws1:9081/schema/">22</ns0:value>
</item>
<item>
<ns0:name xmlns:ns0="http://ectest556ws1:9081/schema/">PASTAZA</ns0:name>
<ns0:value xmlns:ns0="http://ectest556ws1:9081/schema/">16</ns0:value>
</item>
<item>
<ns0:name xmlns:ns0="http://ectest556ws1:9081/schema/">PICHINCHA</ns0:name>
<ns0:value xmlns:ns0="http://ectest556ws1:9081/schema/">17</ns0:value>
</item>
<item>
<ns0:name xmlns:ns0="http://ectest556ws1:9081/schema/">SANTA ELENA</ns0:name>
<ns0:value xmlns:ns0="http://ectest556ws1:9081/schema/">24</ns0:value>
</item>
<item>
<ns0:name xmlns:ns0="http://ectest556ws1:9081/schema/">SANTO DOMINGO DE LOS TSACHILAS</ns0:name>
<ns0:value xmlns:ns0="http://ectest556ws1:9081/schema/">23</ns0:value>
</item>
<item>
<ns0:name xmlns:ns0="http://ectest556ws1:9081/schema/">SUCUMBIOS</ns0:name>
<ns0:value xmlns:ns0="http://ectest556ws1:9081/schema/">21</ns0:value>
</item>
<item>
<ns0:name xmlns:ns0="http://ectest556ws1:9081/schema/">TUNGURAHUA</ns0:name>
<ns0:value xmlns:ns0="http://ectest556ws1:9081/schema/">18</ns0:value>
</item>
<item>
<ns0:name xmlns:ns0="http://ectest556ws1:9081/schema/">ZAMORA CHINCHIPE</ns0:name>
<ns0:value xmlns:ns0="http://ectest556ws1:9081/schema/">19</ns0:value>
</item>
</results>
</opResponse>
</soapenv:Body>
</soapenv:Envelope>
定义<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://POCODM/ObtenerCiudad.tws" xmlns:impl="http://POCODM/ObtenerCiudad.tws" xmlns:impl1="http://ectest556ws1:9081/schema/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:intf="http://POCODM/ObtenerCiudad.tws" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/">
<wsdl:types>
<schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://POCODM/ObtenerCiudad.tws" xmlns="http://www.w3.org/2001/XMLSchema">
<import namespace="http://ectest556ws1:9081/schema/"/>
<element name="op">
<complexType>
<sequence>
<element name="text" type="xsd:string"/>
</sequence>
</complexType>
</element>
<element name="opResponse">
<complexType>
<sequence>
<element name="results" type="impl1:ArrayOf_NameValuePair"/>
</sequence>
</complexType>
</element>
</schema>
<schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://ectest556ws1:9081/schema/" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:impl="http://POCODM/ObtenerCiudad.tws" xmlns:impl1="http://ectest556ws1:9081/schema/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<import namespace="http://POCODM/ObtenerCiudad.tws">
<!--Add URI of the schema document for the imported namespace using 'schemaLocation' attribute.-->
</import>
<complexType name="NameValuePair">
<sequence>
<element maxOccurs="1" minOccurs="0" name="name" nillable="false" type="xsd:string"/>
<element maxOccurs="1" minOccurs="0" name="value" nillable="false" type="xsd:string"/>
</sequence>
</complexType>
<complexType name="ArrayOf_NameValuePair">
<sequence>
<element maxOccurs="unbounded" minOccurs="0" name="item" nillable="true" type="impl1:NameValuePair"/>
</sequence>
</complexType>
<complexType name="ArrayOf_string">
<sequence>
<element maxOccurs="unbounded" minOccurs="0" name="item" nillable="true" type="xsd:string"/>
</sequence>
</complexType>
</schema>
</wsdl:types>
<wsdl:message name="opResponse">
<wsdl:part name="parameters" element="impl:opResponse">
</wsdl:part>
</wsdl:message>
<wsdl:message name="opRequest">
<wsdl:part name="parameters" element="impl:op">
</wsdl:part>
</wsdl:message>
<wsdl:portType name="ObtenerCiudadPortType">
<wsdl:operation name="op">
<wsdl:input name="opRequest" message="impl:opRequest">
</wsdl:input>
<wsdl:output name="opResponse" message="impl:opResponse">
</wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="ObtenerCiudadSoapSoapBinding" type="impl:ObtenerCiudadPortType">
<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="op">
<wsdlsoap:operation soapAction="http://POCODM/ObtenerCiudad.tws/op"/>
<wsdl:input name="opRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="opResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="ObtenerCiudad">
<wsdl:port name="ObtenerCiudadSoap" binding="impl:ObtenerCiudadSoapSoapBinding">
<wsdlsoap:address location="http://ectest556ws1:9081/teamworks/webservices/POCODM/ObtenerCiudad.tws"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
序列化
会得到什么? JSONSerializer serializer = new JSONSerializer();
out.println( serializer.serialize( port.op() ));
ectest556ws1._9081.schema.ArrayOfNameValuePair@6d3f8e {"class":"ectest556ws1._9081.schema.ArrayOfNameValuePair"}
解决方案是像管理XHTMLReques一样管理此响应,解析传入的XML以读取值。