如何从soap响应中的xml获取特定标记

时间:2011-08-12 06:57:33

标签: android xml soap

我是一名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标签,如何获得?

1 个答案:

答案 0 :(得分:0)

解析答案以获取所需的数据或编写一个manualy soap请求以获得您想要的内容。 Whit SAX 例如

要发送手动书面请求,您可以使用this code。要编写soap request / enveloppe,您可以使用 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>