我正在開發一個示例應用程序來調用.Net Web服務。我已將ksoap2-j2me-core-prev-2.1.2.jar添加到Eclipse中的構建路徑中。「該方法不適用於參數」構建BlackBerry應用程序
我通過方法addProperty傳遞了兩個值:「數字1」和10整數,也是「數字2」和20這將導致一個編譯器錯誤:
The method addProperty(String, Object) in the type SoapObject is not applicable for the arguments (String, int)
我怎樣才能解決錯誤,以及如何能我將一個字符串和一個int值傳遞給addProperty?我在Android中以相同的方式完成了這項工作,並且在那裏工作得很好。
String serviceUrl = "URL to webservice";
String serviceNameSpace = "namespace of web service";
String soapAction = "URL to method name";
String methodName = "Name of method";
SoapObject rpc = new SoapObject(serviceNameSpace, methodName);
//compiler error here
rpc.addProperty("number1", 10);
rpc.addProperty("number2", 20);
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.ENC;
HttpTransport ht = new HttpTransport(serviceUrl);
ht.debug = true;
ht.setXmlVersionTag("");
String result = null;
try
{
ht.call(soapAction, envelope);
result = (String) (envelope.getResult());
}
catch(org.xmlpull.v1.XmlPullParserException ex2){
}
catch(Exception ex){
String bah = ex.toString();
}
return result;