0

I am having a lot of trouble finding good information on how to call a standard SOAP web service in Android. any help

venu
  • 2,971
  • 6
  • 40
  • 59

2 Answers2

0

Use this below code to call SOAP web service from Android using NTLM AUTHENTICATION.

  SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    soapEnvelope.implicitTypes = true;
    soapEnvelope.dotNet = true;
    SoapObject soapReq = new SoapObject("urn:microsoft-dynamics-schemas/page/customercard","Read");

    soapEnvelope.setOutputSoapObject(soapReq);

    propinfo = new PropertyInfo();
    propinfo.setName("No");
    propinfo.setValue(no);
    propinfo.setType(no.getClass());
    propinfo.setNamespace("urn:microsoft-dynamics-schemas/page/customercard");
    soapReq.addProperty(propinfo);


    NtlmTransport ntlm = new NtlmTransport(url, userid, password, domainname,systemname);
    try{
        if (headers!=null){
            ntlm.call("urn:microsoft-dynamics-schemas/page/customercard/Read", soapEnvelope,headers);
        }else{
            ntlm.call("urn:microsoft-dynamics-schemas/page/customercard/Read", soapEnvelope);
        }
        Object retObj = soapEnvelope.bodyIn;
        if (retObj instanceof SoapFault){
            SoapFault fault = (SoapFault)retObj;
            Exception ex = new Exception(fault.faultstring);
            if (eventHandler != null)
                eventHandler.Wsdl2CodeFinishedWithException(ex);
        }else{
            SoapObject result=(SoapObject)retObj;
            if (result.getPropertyCount() > 0){
                System.out.println("RESULT 2"+result);
                Object obj = result.getProperty(0);
                SoapObject j = (SoapObject)obj;
           }
i.n.e.f
  • 1,773
  • 13
  • 22
0

First of all you should call a web service through a AsyncTask. You must have a bean class and add internet permission in your manifest file. Check this Example for your reference

Yashwanth
  • 880
  • 3
  • 13
  • 21