我有以下调用.net web 服务的代码。代码很好地连接到服务,但参数(设备ID)似乎没有通过。该方法仅返回传递的始终为 null 的 deviceid。
这告诉我 deviceid 参数没有被传递。我以为我看到有人推荐一个数据包嗅探器来查看传出的 xml,但似乎不记得它是什么了。有人可以推荐一个我可以与eclipse和windows结合使用的。
活动代码
String deviceid = tManager.getDeviceId();
SoapObject request = new SoapObject(NAMESPACE,METHOD_NAME);
PropertyInfo pi = new PropertyInfo();
pi.setName("deviceid");
pi.type = PropertyInfo.STRING_CLASS;
pi.setValue(deviceid.toString());
request.addProperty(pi);
SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
soapEnvelope.dotNet = true;
soapEnvelope.setOutputSoapObject(request);
HttpTransportSE ht = new HttpTransportSE(URL);
try{
ht.call(SOAP_ACTION, soapEnvelope);
SoapPrimitive result = (SoapPrimitive ) soapEnvelope.getResponse();
Toast.makeText(ctx, "result = " + result.toString(), Toast.LENGTH_SHORT).show();
}catch(Exception e){
e.printStackTrace();
Toast.makeText(ctx, "error: " + e.getMessage(), Toast.LENGTH_SHORT).show();
}
网络服务代码
<WebMethod()> _
Public Function CheckTrial(ByVal deviceid As String) As String
Return deviceid
End Function
我已经尝试了一切,但无法弄清楚如何解决这个问题。还有其他人有什么建议可以尝试吗?
从钢丝鲨间谍发送的 xml:
POST /android_service_test.asmx HTTP/1.1
Host: ikonicsoft.com
user-agent: kSOAP/2.0
soapaction: http://ikonicsoft.com/CheckTrial
content-type: text/xml
connection: close
content-length: 421
<?xml version="1.0" encoding="UTF-8"?>
<v:Envelope xmlns:i="http://www.w3.org/2001/XMLSchema-instance"
xmlns:d="http://www.w3.org/2001/XMLSchema"
xmlns:c="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:v="http://schemas.xmlsoap.org/soap/envelope/">
<v:Header />
<v:Body>
<CheckTrial xmlns="http://ikonicsoft.com" id="o0" c:root="1">
<deviceid i:type="d:string">000000000000000</deviceid>
</CheckTrial>
</v:Body>
</v:Envelope>
HTTP/1.1 200 OK
Connection: close
Date: Mon, 21 Jun 2010 16:35:10 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: PleskWin
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Set-Cookie: .ASPXANONYMOUS=fnyqjfFHywEkAAAAZGVjYjZmNTEtNWNiYi00YTIwLWEzYzktNzUxZDNjMDA0OGY00;
expires=Mon, 30-Aug-2010 03:15:09 GMT; path=/; HttpOnly
Cache-Control: private, max-age=0
Content-Type: text/xml; charset=utf-8
Content-Length: 299
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<CheckTrialResponse xmlns="http://ikonicsoft.com/" />
</soap:Body>
</soap:Envelope>
谢谢
帕特里克