将客户设置为Magento中的购物车

时间:2014-11-28 05:29:33

标签: android magento

我正在尝试将现有客户设置为购物车,但我得到了"客户的模式未知"来自API的故障代码。任何人都建议我在设置客户的请求中有什么错误,下面是代码 -

    env = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    env.dotNet = false;
    env.xsd = SoapSerializationEnvelope.XSD;
    env.enc = SoapSerializationEnvelope.ENC;    

    SoapObject customerEntity = new SoapObject(NAMESPACE, "shoppingCartCustomerEntity");
    customerEntity.addProperty("mode",mode);
    customerEntity.addProperty("customer_id",customerId);
    customerEntity.addProperty("firstname",firstname);
    customerEntity.addProperty("lastname",lastname);
    customerEntity.addProperty("email",email);
    customerEntity.addProperty("website_id",1);

    request = new SoapObject(NAMESPACE, "shoppingCartCustomerSet");
    request.addProperty("sessionId", sessionId);
    request.addProperty("quoteId", quoteId);
    request.addProperty("customerData", customerEntity);
    env.setOutputSoapObject(request);

    androidHttpTransport = new HttpTransportSE(URL);
    androidHttpTransport.debug = true;
    (new MarshalHashtable()).register(env);
    try {
        androidHttpTransport.call("", env);

    } catch (IOException | XmlPullParserException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    try {
        result = env.getResponse();
        System.out.println(result);
    } catch (SoapFault e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

3 个答案:

答案 0 :(得分:4)

<强>替换 request.addProperty(“ customerData ”,customerEntity); 的 request.addProperty(“ customer ”,customerEntity);

答案 1 :(得分:0)

试试这个。它可以帮到你。

customerEntity.addProperty("mode","customer");

并添加此字段

customerEntity.addProperty("entity_id","yourid");

答案 2 :(得分:0)

`<complexType name="shoppingCartCustomerEntity">
<all>
<element name="mode" type="xsd:string" minOccurs="0"/>
<element name="customer_id" type="xsd:int" minOccurs="0"/>
<element name="email" type="xsd:string" minOccurs="0"/>
<element name="firstname" type="xsd:string" minOccurs="0"/>
<element name="lastname" type="xsd:string" minOccurs="0"/>
<element name="password" type="xsd:string" minOccurs="0"/>
<element name="confirmation" type="xsd:string" minOccurs="0"/>
<element name="website_id" type="xsd:int" minOccurs="0"/>
<element name="store_id" type="xsd:int" minOccurs="0"/>
<element name="group_id" type="xsd:int" minOccurs="0"/>
</all>
</complexType>`

这是购物车客户实体的wsdl方案。 要检查传递参数以获取进一步的请求:放置&#39; http://yourdomainname//api/v2_soap/?wsdl&#39;在您的网络浏览器中。