gpt4 book ai didi

java - ComplexityObject ksoap2 Android Magento 错误

转载 作者:行者123 更新时间:2023-12-02 05:39:08 25 4
gpt4 key购买 nike

我正在尝试使用 ksoap2 在远程 Magento 安装上创建订单。我能够使用 SOAP v2 Api 执行基本操作,但我陷入了复杂性对象的困境。

这是我尝试与之交互的 wsdl 的一部分

<complexType name="shoppingCartProductEntityArray">
<complexContent>
<restriction base="soapenc:Array">
<attribute ref="soapenc:arrayType" wsdl:arrayType="typens:shoppingCartProductEntity[]"/>
</restriction>
</complexContent>
</complexType>
<complexType name="shoppingCartProductResponseEntityArray">
<complexContent>
<restriction base="soapenc:Array">
<attribute ref="soapenc:arrayType" wsdl:arrayType="typens:catalogProductEntity[]"/>
</restriction>
</complexContent>
</complexType>
.....
<message name="shoppingCartProductAddRequest">
<part name="sessionId" type="xsd:string"/>
<part name="quoteId" type="xsd:int"/>
<part name="products" type="typens:shoppingCartProductEntityArray"/>
<part name="storeId" type="xsd:string"/>
</message>
.....
<operation name="shoppingCartProductAdd">
<documentation>Add product(s) to shopping cart</documentation>
<input message="typens:shoppingCartProductAddRequest"/>
<output message="typens:shoppingCartProductAddResponse"/>
</operation>

我尝试了以下方法

env = getEnvelope();
request = new SoapObject(NAMESPACE, MethodName_AddProduct);
request.addProperty("sessionId",_SessionId );

SoapObject SingleProduct = new SoapObject(NAMESPACE, "shoppingCartProductEntity");
PropertyInfo pi = new PropertyInfo();
pi.setName("product_id");
pi.setValue(Products[0][0]);
pi.setType(String.class);

SingleProduct.addProperty(pi);

pi = new PropertyInfo();
pi.setName("sku");
pi.setValue(Products[0][1]);
pi.setType(String.class);

SingleProduct.addProperty(pi);

pi = new PropertyInfo();
pi.setName("qty");
pi.setValue(1);
pi.setType(Double.class);
SingleProduct.addProperty(pi);

SoapObject EntityArray = new SoapObject(NAMESPACE, "shoppingCartProductEntityArray");
EntityArray.addProperty("productData",SingleProduct);

request.addProperty("quoteId",cartId);
request.addProperty("productsData",EntityArray);
env.setOutputSoapObject(request);
androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.call(SoapAction_AddProduct, env);

但是我收到以下消息

SoapFault - faultcode: '1021' faultstring: 'Product's data is not valid.' faultactor: 'null' detail: null

我还尝试打印对我来说格式正确的请求

DEBUG REQUEST : shoppingCartProductAdd{sessionId=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx; quoteId=31; productsData=shoppingCartProductEntityArray{productData=shoppingCartProductEntity{product_id=1; sku=PLM01; qty=1; }; }; }

最佳答案

我明白了,这是“productsData”

完整代码如下

env = getEnvelope();
request = new SoapObject(NAMESPACE, MethodName_AddProduct);
request.addProperty("sessionId",_SessionId );
request.addProperty("quoteId",cartId);


SoapObject SingleProduct = new SoapObject(NAMESPACE, "shoppingCartProductEntity");
PropertyInfo pi = new PropertyInfo();
pi.setName("product_id");
pi.setValue(Integer.parseInt(Products[0][0]));
pi.setType(Integer.class);

SingleProduct.addProperty(pi);

pi = new PropertyInfo();
pi.setName("sku");
pi.setValue(Products[0][1]);
pi.setType(String.class);

SingleProduct.addProperty(pi);

pi = new PropertyInfo();
pi.setName("qty");
pi.setValue(1);
pi.setType(Double.class);
SingleProduct.addProperty(pi);

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

request.addProperty("products",EntityArray);
env.setOutputSoapObject(request);

关于java - ComplexityObject ksoap2 Android Magento 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24671019/

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