gpt4 book ai didi

java - 如何使用 ArrayOfNameValuePair 从 BPM 使用 SOAP WS?

转载 作者:行者123 更新时间:2023-12-01 12:53:58 25 4
gpt4 key购买 nike

每次我收到 port.op() 的空响应时,我不知道如何读取 ArrayOfNameValuePair

我的java函数

 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 以读取值。

关于java - 如何使用 ArrayOfNameValuePair 从 BPM 使用 SOAP WS?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24026650/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com