Return option and XPath

The element to return is specified using an XPath subject to the following limitations:

  • The element to return must be a scalar type. That is, it cannot be an array or contain another element.
  • Only fully qualified paths are accepted, for example:

    /Message/StockQuote/Price

  • Attributes of elements can be specified using the standard XPath '@' notation, for example:

    /Message/StockQuote/@currency

While the SOAP standard does not forbid the use of attributes, it recommends not using them.

No other XPath syntax is supported

The limitations in the previous examples are taken into consideration in the following sample message:


<Message>
   <StockQuote>
      <Symbol>XYZ</Symbol>
      <Price currency="dollar">20</Price>
  </StockQuote>
</Message>

The names of the elements in the path correspond to the name in the returned data. Therefore, if the -RAW command is used, the names correspond to the element names in the raw response message. In this case, the elements are often qualified by namespace prefixes.

Consider the following example return message:


<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV=http://schemas.xmlsoap.org/soap/envelope/
   xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
   xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<NS1:BabelFishResponse xmlns:NS1="urn:BorlandBabelIntf-IBorlandBabel">
<return xsi:type="xsd:string">Freeend</return>
</NS1:BabelFishResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

If we want to return only the <return> element, the following command(s) should be used:


-RAW -RETURN /SOAP-ENV:Envelope/SOAP-ENV:Body/
NS1:BabelFishResponse/return

Or, if the -RAW command is not specified:


-RETURN /BabelFishResponse/return