我正在尝试使用 ksoap 来调用一个简单的 web 服务。我跟着这个视频尝试开始。当我在信封上调用“getResponse()”时,我只得到字符串“Error”。没有抛出异常或任何其他细节。我已成功连接到我刚刚在本地计算机上设置的简单 Web 服务。这可能与在工作中使用代理服务器有关吗?我的代码如下:
String SOAP_ACTION="http://tempuri.org/CelsiusToFahrenheit";
String METHOD_NAME = "CelsiusToFahrenheit";
String NAMESPACE = "http://tempuri.org";
String URL = "http://w3schools.com/webservices/tempconvert.asmx";
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
PropertyInfo pi = new PropertyInfo();
pi.setName("Celsius");
pi.setValue("32");
request.addProperty(pi);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE aht = new HttpTransportSE(URL);
try
{
aht.call(SOAP_ACTION, envelope);
SoapPrimitive results = (SoapPrimitive)envelope.getResponse();
}
catch (Exception e)
{
e.printStackTrace();
}