各位大大好~
小弟想試著用AndroidAPP寫一個呼叫自己另外用.Net架設的WebService
但是似乎都沒有反應~
不知道是否哪邊出問題了?
下面的Code e.getMessage()都是空值~
所以我才又加一行~把button.text="xxx"
最後運行結果~Button的text都會變成xxx~表示真的有進入exception~
Code如下:
public void doSomething(View v)
{
Button btn = null;
btn=(Button)findViewById(R.id.button1);
String NAMESPACE = "http://tempuri.org/";
String URL = "http://127.0.0.1:2282/service1.asmx";
String SOAP_ACTION = "http://tempuri.org/HelloWorld";
String METHOD_NAME="HelloWorld";
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet=true;
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try
{
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapPrimitive result = (SoapPrimitive)envelope.getResponse();
btn.setText(result.toString());
}
catch(Exception e)
{
e.printStackTrace();
btn.setText(e.getMessage());
btn.setText("xxx");
}
}