tags:

views:

2819

answers:

4

Hai to All, I need to call a webservice("http://192.168.1.19/TestWeb/WebService.asmx") from android.please anyone help me with full source code.

Regards, Rajapandian

A: 

Have a look at here http://www.anddev.org/web_services_-_an_xml-rpc_client_for_android-t646.html

rangalo
Is that link for XML/RPC? He needs SOAP.
John Saunders
yes, it is xml-rpc kxml-rpc to be precise.
rangalo
+1  A: 

Hai, Finally i got the solution for my own question.

Here is the code:

package projects.ksoap2sample;

import org.ksoap2.SoapEnvelope; import org.ksoap2.serialization.SoapObject; import org.ksoap2.serialization.SoapSerializationEnvelope; import org.ksoap2.transport.HttpTransportSE; import android.app.; import android.os.; import android.widget.TextView;

public class ksoap2sample extends Activity { /** Called when the activity is first created. */ private static final String SOAP_ACTION = "http://tempuri.org/HelloWorld";

private static final String METHOD_NAME = "HelloWorld";

private static final String NAMESPACE = "http://tempuri.org/";
private static final String URL = "http://192.168.1.19/TestWeb/WebService.asmx";
TextView tv;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    tv=(TextView)findViewById(R.id.text1);
    call();

}

public void call()
{
 try {

        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);

        request.addProperty("passonString", "Rajapandian");

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

        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
        androidHttpTransport.call(SOAP_ACTION, envelope);

        Object result = (Object)envelope.getResponse();

        tv.setText(result.toString());
    } catch (Exception e) {
        tv.setText(e.getMessage());
        }
}

}

Regards Rajapandian

Rajapandian
A: 

You can find an example here. Hope it helps.

niko
A: 

For complete running sample for calling web service please [see][1]

[1]: http://bimbim.in/post/2010/10/08/Android-Calling-Web-Service-with-complex-types.aspx this post.

bimbim.in