Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //WEB SERVICE
- <WebMethod()> _
- Public Function Hello(ByVal strText As String) As String
- Return "Hello " + strText
- End Function
- //Android CODE
- package com.tt;
- import android.app.Activity;
- import android.os.Bundle;
- import android.view.View;
- import android.view.View.OnClickListener;
- import android.widget.Button;
- import android.widget.EditText;
- import android.widget.TextView;
- import org.ksoap2.SoapEnvelope;
- import org.ksoap2.serialization.PropertyInfo;
- import org.ksoap2.serialization.SoapObject;
- import org.ksoap2.serialization.SoapSerializationEnvelope;
- import org.ksoap2.transport.AndroidHttpTransport;
- public class TrialconActivity extends Activity {
- private static final String SOAP_ACTION = "http://tempuri.org/Hello";
- private static final String METHOD_NAME = "Hello";
- private static final String NAMESPACE = "http://tempuri.org";
- private static final String URL ="http://192.168.75.8/Web%20Service/Service1.asmx";
- public TrialconActivity(){}
- Object result = null;
- EditText ed1;
- TextView password,tv1,tv2;
- Button click;
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- tv1 = (TextView)findViewById(R.id.textView1);
- ed1 = (EditText)findViewById(R.id.eduser);
- click = (Button)findViewById(R.id.button1);
- click.setOnClickListener(new OnClickListener() {
- @SuppressWarnings("deprecation")
- @Override
- public void onClick(View v) {
- try{
- SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
- password = (TextView)findViewById(R.id.edpass);
- String data = password.getText().toString();
- System.out.println("The String is :"+data);
- request.addProperty("strText", data);
- SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
- envelope.dotNet = true;
- envelope.setOutputSoapObject(request);
- AndroidHttpTransport aht=new AndroidHttpTransport(URL);
- aht.call(SOAP_ACTION, envelope);
- result = envelope.getResponse();
- String ans = result.toString();
- ed1.setText(ans);
- }
- catch(Exception e){
- tv1.setText(e.toString());
- }
- }
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement