我需要在我的 android 应用程序中访问 .NET 网络服务。我是使用 ksoap2 库完成的。我设置了连接和一切,但我无法从服务中取回数据。该服务应该发回一组值。我如何捕捉这些价值观?
这是我访问 Web 服务的 java 代码。
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
SoapSerializationEnvelope envelope =
new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
AndroidHttpTransport androidHttpTransport = new AndroidHttpTransport(URL);
try {
androidHttpTransport.call(SOAP_ACTION, envelope);
//code to get back the values here. This is my doubt.
//What code do I write here to get the values from the service ?
} catch (Exception e) {
e.printStackTrace();
}
这是服务响应的格式。
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetControlResponse xmlns="http://tempuri.org/">
<GetControlResult>
<Id>int</Id>
<Belt>boolean</Belt>
<Lighting>boolean</Lighting>
<AutoSpeed>boolean</AutoSpeed>
<ManualSpeed>short</ManualSpeed>
<Projector>boolean</Projector>
<ProjecterPattern>short</ProjecterPattern>
</GetControlResult>
</GetControlResponse>
</soap:Body>
</soap:Envelope>