Java Android:通过SOAP API在magento中创建客户
我试图通过android应用程序中的SOAP API(customerCustomerCreate(SOAP V2))在magento中创建客户,但我遇到了以下错误: SoapFault-faultcode:'100'faultstring:'需要客户电子邮件'faultactor:'null'详细信息:null 我使用以下代码设置电子邮件地址:Java Android:通过SOAP API在magento中创建客户,java,android,api,magento,soap,Java,Android,Api,Magento,Soap,我试图通过android应用程序中的SOAP API(customerCustomerCreate(SOAP V2))在magento中创建客户,但我遇到了以下错误: SoapFault-faultcode:'100'faultstring:'需要客户电子邮件'faultactor:'null'详细信息:null 我使用以下代码设置电子邮件地址: request = new SoapObject(NAMESPACE, "customerCustomerCreate"); req
request = new SoapObject(NAMESPACE, "customerCustomerCreate");
request.addProperty("sessionId", sessionId);
SoapObject value = new SoapObject(NAMESPACE, "associativeEntity");
value.addProperty("key", "in");
value.addProperty("value", "xxxxx@xxxxx.com");
SoapObject complexFilter = new SoapObject(NAMESPACE,
"complexFilter");
complexFilter.addProperty("key", "email");
complexFilter.addProperty("value", value);
SoapObject filterArray = new SoapObject(NAMESPACE,
"complexFilterArray");
filterArray.addProperty("item", complexFilter);
SoapObject filters = new SoapObject(NAMESPACE, "filters");
filters.addProperty("complex_filter", filterArray);
request.addProperty("filters", filters);
env.setOutputSoapObject(request);
androidHttpTransport.call("", env);
result = env.getResponse();
有人知道我在这里做错了什么吗?
如果您在使用此功能之前无法获得答案,请向我表示感谢
public void CreateNewCustomer(String email, String firstname, String lastname, String password) {
try {
env.dotNet = false;
env.xsd = SoapSerializationEnvelope.XSD;
env.enc = SoapSerializationEnvelope.ENC;
request = new SoapObject(NAMESPACE, "login");
request.addProperty("username", "+++++");
request.addProperty("apiKey", "+++++");
env.setOutputSoapObject(request);
public static HttpTransportSE androidHttpTransport = new HttpTransportSE(URL)
androidHttpTransport.call("", env);
session = env.getResponse();
sessionId = session.toString();
Log.d("sessionId", sessionId.toString());
Log.d("Create "," Creating......");
request = new SoapObject(NAMESPACE,"customerCustomerCreate");
request.addProperty("sessionId", sessionId);
// request.addProperty("product", product_id);
//-----use Kvm Serializable class to serialize the key value data-------
CreateCustomerKVMserialize createcustomerkvm = new CreateCustomerKVMserialize();
createcustomerkvm.Email = email;
createcustomerkvm.Firstname = firstname;
createcustomerkvm.Lastname = lastname;
createcustomerkvm.Password = password;
PropertyInfo pi = new PropertyInfo();
pi.setName("customerData");
pi.setValue(createcustomerkvm);
pi.setType(createcustomerkvm.getClass());
request.addProperty(pi);
env.setOutputSoapObject(request);
env.addMapping(NAMESPACE, "customerData",new CreateCustomerKVMserialize().getClass());
androidHttpTransport.call("", env);
Object customer_create = env.getResponse();
Log.d("mainactivity "," "+customer_create.toString());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (XmlPullParserException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
---------CreateCustomerKVMserialize类-----------
使用以下代码:
SoapObject request = new SoapObject(NAMESPACE, "customerCustomerCreate");
request.addProperty("sessionId", sessionId);
SoapObject customerEntity = new SoapObject(NAMESPACE, "customerCustomerEntityToCreate");
customerEntity.addProperty("email", "abqpo@120.com");
customerEntity.addProperty("firstname", "firstname");
customerEntity.addProperty("lastname", "lastname");
request.addProperty("customerData", customerEntity);
env.setOutputSoapObject(request);
androidHttpTransport.call("", env);
Object result = env.getResponse();
String custId = result.toString();
其中env是SoapSerializationEnvelope谢谢大家,它工作得很好,只是我必须指定WebsiteId、StoreId和GroupId,您已经注释掉了。请在这里帮我:@babyncoding,对不起,我很久以前就做过这个了。无论如何,如果有任何积极的事情,我会看一看并告诉你。@remeemssyde谢谢你的支持。@remeemssyde我发布了新问题,请检查这里:
SoapObject request = new SoapObject(NAMESPACE, "customerCustomerCreate");
request.addProperty("sessionId", sessionId);
SoapObject customerEntity = new SoapObject(NAMESPACE, "customerCustomerEntityToCreate");
customerEntity.addProperty("email", "abqpo@120.com");
customerEntity.addProperty("firstname", "firstname");
customerEntity.addProperty("lastname", "lastname");
request.addProperty("customerData", customerEntity);
env.setOutputSoapObject(request);
androidHttpTransport.call("", env);
Object result = env.getResponse();
String custId = result.toString();