在机器人如何在Magento使用kso​​ap2库发送复杂的阵列? [英] In android how to send complex array in magento using ksoap2 library?

查看:242
本文介绍了在机器人如何在Magento使用kso​​ap2库发送复杂的阵列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一系列复杂的像:

 的$ id =值;

$顾客=阵列(钥匙=>中值,键=>中值);

$设置= $基于SOAP>调用($会话ID,'abc.set,数组($ ID,$用户));
 

如何发送申请表的android这种类型的复杂阵列的肥皂。

我使用 ksoap2 库发送请求的磁肥皂。

在调用此类型的复杂阵列喜欢的soapUI软件格式化:

 < SOAP-ENV:信封SOAP-ENV:encodingStyle的=htt​​p://schemas.xmlsoap.org/soap/encoding/的xmlns:SOAP-ENV =HTTP: //schemas.xmlsoap.org/soap/envelope/的xmlns:NS1 =金塔: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/编码/>
   < SOAP-ENV:身体与GT;
      <调用>
         <的sessionId的xsi:type =XSD:字符串> ??< /的sessionId>
         < resourcePath的xsi:type =XSD:字符串> abc.set< / resourcePath>
         <的args的xsi:type =SOAP-ENC:Array一个>
            <项目的xsi:type =XSD:INT> ID< /项目>
            <项目的xsi:type =NS2:地图>
               <项目>
                  <关键的xsi:type =XSD:字符串>键< /键>
                  <值的xsi:type =XSD:字符串>值小于/值GT;
               < /项目>
               <项目>
                  <关键的xsi:type =XSD:字符串>键< /键>
                  <值的xsi:type =XSD:字符串>值小于/值GT;
               < /项目>
               <项目>
                  <关键的xsi:type =XSD:字符串>键< /键>
                  <值的xsi:type =XSD:字符串>值小于/值GT;
               < /项目>
            < /项目>
         < / ARGS>
      < /呼叫>
   < / SOAP-ENV:身体与GT;
< / SOAP-ENV:信封>
 

解决方案

第1步:在KSOAP或ksoap2不直接支持发送阵列。这样你就可以创建一个方法名SoapObject(您需要创建数组)

  SoapObject对象=新SoapObject(命名空间shoppingCartProductEntity);
中Object.addProperty(PRODUCT_ID,886);
中Object.addProperty(SKU,ABC 456黑10);
         多参数.....
 

第二步:,然后创建arrayType中方法(可选取决于您的WSDL),这soapObject添加到该数组对象为属性

  SoapObject EntityArray =新SoapObject(命名空间shoppingCartProductEntityArray);
EntityArray.addProperty(产品,对象);
 

第三步:终于在阵列中添加到您的主SOAP调用

  SoapObject请求=新SoapObject(命名空间shoppingCartProductAdd);
request.addProperty(的sessionId的sessionId);
request.addProperty(quoteId,cartId);
request.addProperty(产品,EntityArray); // ADDING ARRAY这里作为一个PEOPERTY
env.setOutputSoapObject(要求);
androidHttpTransport.call空间(namespace +/ shoppingCartProductAdd,ENV);
resultSoap = env.getResponse();
 

注:以下步骤改变依赖于你的WSDL,有时可以直接加入第一步对象作为参数,这依赖于WSDL

Complex Array Like :

$id = "value";

$customer = array("key" => "value", "key" => "value");

$set = $soap->call($sessionID, 'abc.set', array($id, $customer));

How to send request form android with this type of complex array in soap.

I am using ksoap2 library for sending request in magneto soap.

In SoapUi Software formatting of calling this type of complex array like :

<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>

解决方案

Step 1 : In ksoap or ksoap2 no direct support to send Array. so you can create a SoapObject with method name(which you need to create array)

SoapObject object= new SoapObject(NAMESPACE,"shoppingCartProductEntity");
object.addProperty("product_id","886");
object.addProperty("sku","ABC 456-Black-10");
         and more parameters.....

Step 2 : then create arrayType method(optional depends on your WSDL) and add this soapObject to that array Object as a property

SoapObject EntityArray = new SoapObject(NAMESPACE, "shoppingCartProductEntityArray");
EntityArray.addProperty("products",object);

Step 3 : finally add the array to your main soap call

SoapObject request = new SoapObject(NAMESPACE,"shoppingCartProductAdd");
request.addProperty("sessionId", sessionId);
request.addProperty("quoteId", cartId);
request.addProperty("products",EntityArray); //ADDING ARRAY HERE AS A PEOPERTY
env.setOutputSoapObject(request);
androidHttpTransport.call(NAMESPACE +"/shoppingCartProductAdd ", env);
resultSoap = env.getResponse();

NOTE : the steps varies depends on the your WSDL, sometimes you can directly add 1st step object as a parameter, this depends on WSDL.

这篇关于在机器人如何在Magento使用kso​​ap2库发送复杂的阵列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆