4

I am new to Magento SOAP api , and i am just fetching the session ID by giving the correct user name and API key in my android application . But i am getting error in this following line .

            androidHttpTransport.call("", env);

I have given Internet Permission to my android code and this is the code i am trying with . and I am using KSoap2 android external JAR file and I have added it to my build path .

Please help me

public class MainActivity extends Activity {
private static final String NAMESPACE = "urn:Magento";
private static final String URL = "http://127.0.0.1/index.php/api/v2_soap/";
@Override
protected void onCreate(Bundle savedInstanceState) {
    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", "cats");
        request.addProperty("apiKey", "sudhir123");
        env.setOutputSoapObject(request);
        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
        androidHttpTransport.call("", env);
        Object result = env.getResponse();
        Log.d("sessionId", result.toString());
    } catch (Exception e) {
        e.printStackTrace();
    }
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}

}

  • are you using any custom shipping method. – Baby in Magento Jan 4 '16 at 19:03
5

I got the answer by replacing this

http://127.0.0.1/index.php/api/v2_soap/";

by

http://machines Ip address/index.php/api/v2_soap/";

and I started to use V2 soap api. Its working fine.

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.