0

I am able to 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

Can anyone tell me what is wrong with my code and please provide any solution for this. Thanks in advance.

0

I got the solution. If anybody still facing the problem then try this:

 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();

It's working fine for me. All you have to do is just change the name "addressdata" as addressData.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.