![](/img/trans.png)
[英]How to get the value of an xml element from within a SOAP response? (Android)
[英]How to get specific tag from an xml in soap response
我是一名 android 开发人员,我使用 SOAP 从服务器获取 xml 格式的响应。 下面是我正在使用的代码:
SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE,OPERATION_NAME);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE httpTransport = new HttpTransportSE(SOAP_ADDRESS);
try
{
httpTransport.call(SOAP_ACTION, envelope);
Object response = envelope.getResponse();
textView.setText(response.toString());
}
catch (Exception exception)
{
textView.setText(exception.toString());
}
我收到 xml 标签格式的响应,但我只需要响应中的 photourl 标签,如何获得?
解析答案以获取所需的数据或手动编写 soap 请求以仅获取您想要的内容。 例如 Whit SAX
要发送手动书面请求,您可以使用此代码。 要编写 soap 请求/信封,您可以使用soapUI软件来执行此操作,如下所示:
<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"
xmlns:plan=\"http://...\" xmlns:com=\"...\">
<soapenv:Header/>
<soapenv:Body>
<plan:..>
<com:..> ... </com:..>
</plan:..>
</soapenv:Body>
</soapenv:Envelope>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.