I am trying to extract variable from the request and assign the extracted variable to the response. But in assign message the variable extracted is not accessible. Please help. Here's the relevant code.
The ExtractMessage policy:
<ExtractVariables name="Extract-Variables-1"> <Source>request</Source> <XMLPayload> <Namespaces> <Namespace prefix="dir">urn:43BFF88D-D204-4427-B6BA-140AF393142F</Namespace> </Namespaces> <Variable name="travelmode" type="string"> <XPath>/dir:Directions/dir:route/dir:leg/dir:step/@mode</XPath> </Variable> <Variable name="duration" type="string"> <XPath>dir:Directions/dir:route/dir:leg/dir:step/dir:duration/dir:value</XPath> </Variable> <Variable name="timeunit" type="string"> <XPath>/dir:Directions/dir:route/dir:leg/dir:step/dir:duration/dir:text</XPath> </Variable> </XMLPayload> </ExtractVariables>
AssignMessage policy:
<AssignMessage name="Assign-Message-1"> <AssignVariable> <Name>appSecret</Name> <Value>Data2</Value> </AssignVariable> <AssignVariable> <Name>AssignVar</Name> <Value>Data1</Value> </AssignVariable> <AssignTo createNew="false" type="response"/> <Set> <Payload> <Tamatar>{appSecret}</Tamatar> <Aloo>{AssignVar}</Aloo> </Payload> </Set> <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables> </AssignMessage>
I am trying to extract data from the request by using Extract message policy and then want to return one of the extracted variables into the response. Hence extract is in the PREFLOW and Assign Policy is in the Post Flow.
The Request XML is :
<Directions xmlns="urn:43BFF88D-D204-4427-B6BA-140AF393142F"> <status>OK</status> <route> <summary>I-40 W</summary> <leg> <step mode="DRIVING"> <start_location> <lat>41.8507300</lat> <lng>-87.6512600</lng> </start_location> <end_location> <lat>41.8525800</lat> <lng>-87.6514100</lng> </end_location> <duration> <value>19</value> <text>minutes</text> </duration> </step> </leg> </route> </Directions>
Thanks,
Nishith