.Net Webサービスを呼び出すサンプルアプリケーションを開発しています。 Eclipseのビルドパスにksoap2-j2me-core-prev-2.1.2.jarを追加しました。"メソッドは引数には適用されません"
私は、メソッドaddProperty介して2つの値を渡しています:「番号1」と10整数として、また、「number2の」と20。これは、コンパイルエラーが発生します。
The method addProperty(String, Object) in the type SoapObject is not applicable for the arguments (String, int)
どのようにエラーを解決することができますし、どのようにすることができますがaddPropertyに1つの文字列と1つのint値を渡しますか?私はこれを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;