In my App, create a customer using customerCustomerCreate API, and getting the customer id. Now my requirement is to create the address of the customer, for that i am calling the customerAddressCreate api. but somehow i am not able to create the customer address. I
Tried with the code below:
try {
SoapSerializationEnvelope env = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
env.dotNet = false;
env.xsd = SoapSerializationEnvelope.XSD;
env.enc = SoapSerializationEnvelope.ENC;
SoapObject request = new SoapObject(NAMESPACE, "login");
request.addProperty("username", "user");
request.addProperty("apiKey", "apikey");
env.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.call("", env);
Object result = env.getResponse();
Log.e("sessionId", result.toString());
String sessionId = result.toString();
request = new SoapObject(NAMESPACE, "customerAddressCreate");
request.addProperty("sessionId", sessionId);
request.addProperty("customerId",custId);
SoapObject customerEntity = new SoapObject(NAMESPACE, "customerAddressEntityCreate");
customerEntity.addProperty("city", "bangalore");
customerEntity.addProperty("company", "outthinking");
customerEntity.addProperty("country_id", "01");
customerEntity.addProperty("fax", "08012345");
customerEntity.addProperty("firstname", "amit");
customerEntity.addProperty("lastname", "chandra");
customerEntity.addProperty("middlename", "raj");
customerEntity.addProperty("postcode", "560007");
customerEntity.addProperty("prefix", "a");
customerEntity.addProperty("region_id", 03);
customerEntity.addProperty("region", "karnataka");
customerEntity.addProperty("street",Arrays.toString(myStrings));
customerEntity.addProperty("suffix", "ac");
customerEntity.addProperty("telephone", "+91-9962025341");
customerEntity.addProperty("is_default_billing", false);
customerEntity.addProperty("is_default_shipping", false);
request.addProperty("addressdata", customerEntity);
} catch (Exception e) {
e.printStackTrace();
}
where myStrings is array of string of street. But i am getting the following error:
SoapFault - faultcode: '100' faultstring: 'Please enter the first name.
Please enter the last name.
Please enter the street.
Please enter the city.
Please enter the telephone number.
Please enter the zip/postal code.
Please enter the country.' faultactor: 'null' detail: null
What is wrong with my code? Provide solution for this?
I got the solution. If any body still facing the problem, then please try with this code. it worked for me.
request = new SoapObject(NAMESPACE, "customerAddressCreate");
request.addProperty("sessionId", sessionId);
//int customerId = Integer.parseInt(custId);
request.addProperty("customerId","custId");
SoapObject customerEntity = new SoapObject(NAMESPACE, "customerAddressEntityCreate");
customerEntity.addProperty("city", "city");
customerEntity.addProperty("company","");
customerEntity.addProperty("country_id", "IN");
customerEntity.addProperty("fax", "");
customerEntity.addProperty("firstname", fname);
customerEntity.addProperty("lastname", lName);
customerEntity.addProperty("middlename", "");
customerEntity.addProperty("postcode", zipCode);
customerEntity.addProperty("prefix", "");
customerEntity.addProperty("region_id",1);
customerEntity.addProperty("region", region);
SoapObject streetEntity = new SoapObject(NAMESPACE, "street");
streetEntity.addProperty("street", street1);
//streetEntity.addProperty("street", street2);
customerEntity.addProperty("street",streetEntity);
customerEntity.addProperty("suffix", "");
customerEntity.addProperty("telephone", "8147555522");
customerEntity.addProperty("is_default_billing", true);
customerEntity.addProperty("is_default_shipping", false);
request.addProperty("addressData", customerEntity);
env.setOutputSoapObject(request);
androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.call("", env);
result = env.getResponse();
All you have to do is just change the name "addressdata" to addressData.