Java ComplexityObject ksoap2 Android Magento错误
我试图使用ksoap2在远程Magento安装上创建订单。我能够使用SOAPv2API执行基本操作,但是我被一个复杂的对象卡住了 这是我试图与之接口的wsdl的一部分Java ComplexityObject ksoap2 Android Magento错误,java,android,magento,soap,Java,Android,Magento,Soap,我试图使用ksoap2在远程Magento安装上创建订单。我能够使用SOAPv2API执行基本操作,但是我被一个复杂的对象卡住了 这是我试图与之接口的wsdl的一部分 <complexType name="shoppingCartProductEntityArray"> <complexContent> <restriction base="soapenc:Array"> <attribute ref="soapenc:arrayType" wsdl:a
<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>
但我得到了以下信息
SoapFault-faultcode:'1021'faultstring:'产品的数据不正确
有效。'faultactor:'null'详细信息:null
我还尝试打印我认为格式正确的请求
调试请求:
shoppingCartProductAdd{sessionId=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx;
quoteId=31;productsData=shoppingCartProductEntityArray{productData=shoppingCartProductEntity{product_id=1;
sku=PLM01;数量=1;};};};}
我知道了,是“产品数据”
完成下面的代码
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);
我认为您需要传递与wsdl中提到的参数名称相同的参数。您到底指的是什么?wsdl声明shoppingCartProductEntityArray应该是命名产品,对吗?
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);