Extract Variable Policy XPath in SOAP Preflow Request

pxzxz1
New Member

Hi Apigeeks

Can someone kindly explain the definition of the xPath for me?

  • local-name(/*)
  • local-name(/*/*[local-name() = 'Body'])
  • namespace-uri(/*)
  • local-name(//*[local-name() = 'Body']/*[1])
<XMLPayload stopPayloadProcessing="false">
    <Variable name="envelope" type="String">
        <XPath>local-name(/*)</XPath>
    </Variable>
    <Variable name="body" type="String">
        <XPath>local-name(/*/*[local-name() = 'Body'])</XPath>
    </Variable>
    <Variable name="envelopeNamespace" type="String">
        <XPath>namespace-uri(/*)</XPath>
    </Variable>
    <Variable name="operation" type="String">
        <XPath>local-name(//*[local-name() = 'Body']/*[1])</XPath>
    </Variable>
</XMLPayload>

In addition, placing ExtractVariable policy in Preflow Request, the extract of variable is the request payload or the response?

Solved Solved
0 3 498
1 ACCEPTED SOLUTION

You are asking a question about xpath. This is not specific to Apigee.

I can offer some help.

expression meaning
local-name(/*) the local name of the very first, root element of the XML document. "local" means non-namespace qualified and with no prefix. In a SOAP document, this will return "Envelope".
local-name(/*/*[local-name() = 'Body']) The local name of the child of the root element, which has a local-name of 'Body'. This will always result to "Body" if there is a child of the root element called "Body" in the document.
namespace-uri(/*) the namespace of the root element. In a SOAP document, this will return the soap namespace URI. SOAP 1.1 uses namespace http://schemas.xmlsoap.org/wsdl/soap/
SOAP 1.2 uses namespace http://schemas.xmlsoap.org/wsdl/soap12/
(the final expression you cited) That gives the first child element of <Body>. In a SOAP document, it's the soap request element. This is usually the operation in the WSDL.

If these explanations are not clear, I suggest that you read some documentation and tutorials on xpath. For suggestions, LMGTFY.

placing ExtractVariable policy in Preflow Request, the extract of variable is the request payload or the response?

The ExtractVariables policy takes a Source configuration option. Check the documentation for the policy for details on how it works.

Having said that, if the proxy is in the request preflow, there is no response payload. The proxy hasn't received the response payload yet. The response doesn't exist. So there is no possibility for the ExtractVariables attached to the request preflow to operate on the response. If you tried to configure it that way, it would fail at runtime.

View solution in original post

3 REPLIES 3

You are asking a question about xpath. This is not specific to Apigee.

I can offer some help.

expression meaning
local-name(/*) the local name of the very first, root element of the XML document. "local" means non-namespace qualified and with no prefix. In a SOAP document, this will return "Envelope".
local-name(/*/*[local-name() = 'Body']) The local name of the child of the root element, which has a local-name of 'Body'. This will always result to "Body" if there is a child of the root element called "Body" in the document.
namespace-uri(/*) the namespace of the root element. In a SOAP document, this will return the soap namespace URI. SOAP 1.1 uses namespace http://schemas.xmlsoap.org/wsdl/soap/
SOAP 1.2 uses namespace http://schemas.xmlsoap.org/wsdl/soap12/
(the final expression you cited) That gives the first child element of <Body>. In a SOAP document, it's the soap request element. This is usually the operation in the WSDL.

If these explanations are not clear, I suggest that you read some documentation and tutorials on xpath. For suggestions, LMGTFY.

placing ExtractVariable policy in Preflow Request, the extract of variable is the request payload or the response?

The ExtractVariables policy takes a Source configuration option. Check the documentation for the policy for details on how it works.

Having said that, if the proxy is in the request preflow, there is no response payload. The proxy hasn't received the response payload yet. The response doesn't exist. So there is no possibility for the ExtractVariables attached to the request preflow to operate on the response. If you tried to configure it that way, it would fail at runtime.

Hello @dino-at-google

Thank you for the explanation. The ExtractVariable policy is auto generated when I created the SOAP proxy. That being said, what is the meaning of the policy to be built at preflow request?

I don't understand this

what is the meaning of the policy to be built at preflow request?

I think you are asking, why is the policy in the preflow.

And it's probably designed to extract the Envelope and the Body, to verify that the inbound request is a well-formed soap message. I'm inferring.