我想從使用ksoap庫的Android客戶端調用Web服務。無法從Android客戶端調用C#.net Web服務方法
這裏是我的Android代碼
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.16.0.230/WebService/Test.asmx";
TextView tv;
public void call()
{
try {
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("name", "zawoad");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet=true;
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.call(SOAP_ACTION, envelope);
String result = (String)envelope.getResponse();
tv.setText(result);
} catch (Exception e) {
tv.setText("exception :" + e.getLocalizedMessage());
}
}
,這裏是這是寫在Test.asmx我的web服務方法文件
[WebMethod]
public string HelloWorld(string name)
{
return "Hello World" + name;
}
在執行androidHttpTransport.call(SOAP_ACTION, envelope);
線,它拋出以下異常
org.xmlpull.v1.XmlPullParserException:expected:START_TAG {http://schemas.xmlsoap.org/so AP /信封/}信封(位置:START_TAG @ 2:44 [email protected])
請幫助..