My webservice which was working fine, all of a suddenly it has stopped working. I see no exceptions in the logcat. I can invoke the webmethod of the service from the browser of my android device but its not working from my android app. here is my code

public class WebDataManipulator {

private final String NAMESPACE = "http://tempuri.org/";
private final String URL = "http://192.168.5.64/HostedRASService/DataManipulationService.asmx";
private final String METHOD = "InsertData";
private final String SOAP_ACTION = "http://192.168.5.64/HostedRASService/DataManipulationService.asmx/InsertData";

public void insertData() {
    SoapObject request = new SoapObject(NAMESPACE, METHOD);

    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    envelope.dotNet = true;
    envelope.setOutputSoapObject(request);

    System.out.println(request);
    HttpTransportSE androidHttp = new HttpTransportSE(URL);


    try {
        androidHttp.call(SOAP_ACTION, envelope);
    } catch(Exception ex) {
        ex.printStackTrace();
    }
}

Any ideas why it is not working now?

I have solved this issue myself. I am pointing out my mistake here so that it can be useful for the users who may face the similar issue and find this post in the future.

The mistake I commited here is that I did not change the default Namespace for my .NET web service. For .NET web services to work from android, you have to change the default namespace i.e. http://tempuri.org

On the android side, you need to set your SOAP_ACTION as YOURNAMESPACE/METHODNAME. That's it! You can now call the web service from your android device.

Enjoy!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.