私は.Net Webサービスを呼び出すためのサンプルアプリケーションを開発しています。 Eclipseのビルドパスにksoap2-j2me-core-prev-2.1.2.jarを追加しました。
私は2つの値をaddProperty経由で渡しています: "number1"と10、また "number2"と20。これはコンパイラエラーを引き起こします:
型SoapObjectのaddProperty(String、Object)メソッドは、引数(String、int)には適用できません。
エラーを解決するにはどうすればよいですか?また、1つの文字列と1つの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;