简体   繁体   中英

How to get specific tag from an xml in soap response

I am an android developer and I use SOAP to get responses from the server in xml format. Below is the code I am using:

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());         
}

I am getting response in xml tag format but I need only photourl tag from the response, how to get that?

Parse the answer to get the needed datas or write a manualy soap request to get only what you want. Whit SAX for example

To send a manualy written request you can use this code which works. To write the soap request/enveloppe you can use soapUI software which do that, this looks like:

            <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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM