我创建了一个 Web 服务来测试通过 ksoap2 传递的参数。我认为这似乎是一个非常简单的过程,但我显然缺少一些简单的东西。Web 服务只是返回传递给它的整数。当我执行下面的代码时,它返回数字 0 而不是 1。
private static String SOAP_ACTION = "http://tempuri.org/TestParams";
private static String NAMESPACE = "http://tempuri.org/";
private static String METHOD_NAME = "TestParams";
private static String URL = "http://services.lockrem.com/WebService.asmx?WSDL";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("RoundId", 1);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try {
androidHttpTransport.call(SOAP_ACTION, envelope);
} catch (Exception e) {
e.printStackTrace();
}
SoapObject result = (SoapObject)envelope.bodyIn;
注意:我已经使用 .net 网页对此进行了测试,它按预期返回数字 1。Web 服务不是这里的问题。
这是网络服务。
[WebMethod]
public int TestParams(int RoundId)
{
return RoundId;
}
感谢您的任何帮助。