java-在android中如何使用kso​​ap2库在magento中发送复杂数组?

java-在android中如何使用kso​​ap2库在magento中发送复杂数组?,第1张

概述复杂数组如:$id="value";$customer=array("key"=>"value","key"=>"value");$set=$soap->call($sessionID,'abc.set',array($id,$customer));如何在Soap中使用这种复杂数组发送请求表单android.我正在使用kso

复杂数组如:

$ID = "value";$customer = array("key" => "value", "key" => "value");$set = $soap->call($sessionID, 'abc.set', array($ID, $customer));

如何在Soap中使用这种复杂数组发送请求表单androID.

我正在使用kso​​ap2库在磁香皂中发送请求.

在SoapUi软件中,调用此类复杂数组的格式如下:

<SOAP-ENV:Envelope SOAP-ENV:enCodingStyle="http://schemas.xmlsoap.org/soap/enCoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:Magento" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns2="http://xml.apache.org/xml-soap" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/enCoding/">   <SOAP-ENV:Body>      <call>         <sessionID xsi:type="xsd:string">??</sessionID>         <resourcePath xsi:type="xsd:string">abc.set</resourcePath>         <args xsi:type="SOAP-ENC:Array">            <item xsi:type="xsd:int">ID</item>            <item xsi:type="ns2:Map">               <item>                  <key xsi:type="xsd:string">key</key>                  <value xsi:type="xsd:string">value</value>               </item>               <item>                  <key xsi:type="xsd:string">key</key>                  <value xsi:type="xsd:string">value</value>               </item>               <item>                  <key xsi:type="xsd:string">key</key>                  <value xsi:type="xsd:string">value</value>               </item>            </item>         </args>      </call>   </SOAP-ENV:Body></SOAP-ENV:Envelope>

解决方法:

步骤1:在ksoap或ksoap2中,不直接支持发送Array.因此您可以使用方法名称创建SoapObject(需要创建数组)

SoapObject object= new SoapObject(nameSPACE,"shopPingCartProductEntity");object.addProperty("product_ID","886");object.addProperty("sku","ABC 456-Black-10");         and more parameters.....

步骤2:然后创建arrayType方法(可选,取决于您的WSDL)并将此soapObject作为属性添加到该数组Object

SoapObject EntityArray = new SoapObject(nameSPACE, "shopPingCartProductEntityArray");EntityArray.addProperty("products",object);

步骤3:最后将数组添加到您的主Soap调用中

SoapObject request = new SoapObject(nameSPACE,"shopPingCartProductAdd");request.addProperty("sessionID", sessionID);request.addProperty("quoteID", cartID);request.addProperty("products",EntityArray); //ADDING ARRAY HERE AS A PEOPERTYenv.setoutputSoapObject(request);androIDhttpTransport.call(nameSPACE +"/shopPingCartProductAdd ", env);resultSoap = env.getResponse();

注意:步骤取决于您的WSDL,有时您可以直接添加第一步对象作为参数,这取决于WSDL.

总结

以上是内存溢出为你收集整理的java-在android中如何使用kso​​ap2库在magento中发送复杂数组?全部内容,希望文章能够帮你解决java-在android中如何使用kso​​ap2库在magento中发送复杂数组?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1094081.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-28
下一篇 2022-05-28

发表评论

登录后才能评论

评论列表(0条)

保存