0
我是黑莓新手&使用ksoap方法調用WCF服務。 當我打電話給服務時,它會在模擬器上給出錯誤消息。 錯誤是:意外的類型(position:text - uuid:dcd5cdf3 .. @ 3:13 in [email protected])
意想不到的類型(位置:文本 - UUID:dcd5cdf3 .. @在[email protected] 3:13)
該服務成功點網致電。
我的代碼:
String serviceUrl = "<service url>";
String serviceNameSpace ="<service namespaces>";
String soapAction = "<service soapaction>";
String methodName = "logOn";
SoapObject rpc = new SoapObject(serviceNameSpace, methodName);
//String a="52";
//String b="28";
rpc.addProperty("username", String.valueOf(edUserName.getText()));
rpc.addProperty("password",String.valueOf(edPaswd.getText()));
// rpc.addProperty("a","nil");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.bodyOut = rpc;
envelope.dotNet = true; //IF you are accessing .net based web service this should be true
envelope.encodingStyle = SoapSerializationEnvelope.XSD;
//HttpTransport ht = new HttpTransport(serviceUrl);
HttpTransport ht = new HttpTransport(serviceUrl + "; deviceside=true; apn=blackberry.net");
ht.debug = true;
//SoapObject result=null;
//ht.setXmlVersionTag("");
try
{
ht.call(soapAction, envelope);
String result = (envelope.getResponse()).toString();
Dialog.alert(result);
Dialog.alert("login success");
}
catch(Exception ex2)
{
Dialog.alert("error is :"+ex2.getMessage());
}
// if((edUserName.getText().equals("")))
// {
// Dialog.alert("Enter User Name ");
// }
// if(edPaswd.getText().equals(""))
// {
// Dialog.alert("Enter Password");
//
// }
plz告訴我一個在我的代碼中的實際問題以及需要進行哪些更改? – 2011-04-12 05:53:44
我不確定你需要更改代碼的位置。我鏈接的帖子指出,唯一影響BB代碼的是服務URL指向「http:// localhost ...」而不是「http://主機名...」。其他的一切都是爲了檢查你的web服務是否正常工作。 – 2011-04-12 13:11:29
在該論壇中,似乎正在使用的庫無法解析HTTP錯誤消息。它看起來像你的代碼不能用「uuid:dcd5cdf3 ...」解析這個字符串。你確定你的web服務正在發送有效的SOAP/XML嗎? – 2011-04-12 13:15:31