【问题标题】:How to get specific tag from an xml in soap response如何从soap响应中的xml获取特定标签
【发布时间】:2011-08-12 17:03:45
【问题描述】:

我是一名 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 库?

标签: android xml soap


【解决方案1】:

解析答案以获取所需的数据或编写手动肥皂请求以仅获取您想要的内容。以 SAX 为例

要发送手动书面请求,您可以使用this code,这很有效。要编写肥皂请求/信封,您可以使用 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>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-03
    • 1970-01-01
    • 2018-04-10
    • 2021-12-13
    • 1970-01-01
    相关资源
    最近更新 更多