SoapSerializationEnvelope error in android app code
-
13-12-2019 - |
Question
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);
}
}
Solution
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.
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange