java通过ksoap调用_使用ksoap使用android调用ASP.NET Web服务

我为调用Web服务创建了一个简单的类

public class CallSoap {public final String SOAP_ACTION =“http://tempuri.org/Add”;

public final String OPERATION_NAME = "Add";

public final String WSDL_TARGET_NAMESPACE = "http://tempuri.org/";

public final String SOAP_ADDRESS = "http://localhost:41614/Service1.asmx";

public CallSoap()

{

}

public String Call(int a,int b)

{

SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE,OPERATION_NAME);

request.addProperty("a",a);

request.addProperty("b",b);

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);

envelope.dotNet = true;

envelope.setOutputSoapObject(request);

HttpTransport httpTransport = new HttpTransport(SOAP_ADDRESS);

Object response=null;

try

{

httpTransport.call(SOAP_ACTION, envelope);

response = envelope.getResponse();

}

catch (Exception exception)

{

response=exception.toString();

}

return response.toString();

}

}

这是我的Activity点击方法

public void clickData(View v){// Intent intent = new Intent(this,DisplayMessageActivity.class); EditText et =(EditText)findViewById(R.id.editText1); EditText et2 =(EditText)findViewById(R.id.editText2); TextView tv =(TextView)findViewById(R.id.textView1);

int a=Integer.parseInt(et.getText().toString());

int b=Integer.parseInt(et2.getText().toString());

CallSoap cs=new CallSoap();

tv.setText(cs.Call(a, b));

}

有一个错误“不幸的是App1已经sttoped” . 请帮我..

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值