Hi All,
I’m facing issues in trying to combine 2 XML responses into using APIGEE mashup. Below is my configuration:
XML Payload 1:
<root>
<parent>
<fname>A</fname>
</parent>
<parent>
<fname>B</fname>
</parent>
<parent>
<fname>C</fname>
</parent>
</root>
Callout Service 1:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ServiceCallout async="false" continueOnError="false" enabled="true" name="callout_service_1">
<DisplayName>callout_service_1</DisplayName>
<Properties/>
<Request clearPayload="true" variable="myRequest">
<IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
</Request>
<Response>calloutResponse_1</Response>
<HTTPTargetConnection>
<Properties/>
<URL>https://localhost:8080/getService1</URL>
</HTTPTargetConnection>
</ServiceCallout>
Extract Variables 1:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ExtractVariables async="false" continueOnError="false" enabled="true" name="extract_service_1">
<DisplayName>extract_service_1</DisplayName>
<Properties/>
<Source clearPayload="false">calloutResponse_1</Source>
<VariablePrefix>detailResponse1</VariablePrefix>
<XMLPayload stopPayloadProcessing="false">
<Variable name="parent" type="nodeset">
<XPath>//root/parent</XPath>
</Variable>
</XMLPayload>
</ExtractVariables>
XML Payload 2:
<root>
<parent>
<fname>D</fname>
</parent>
<parent>
<fname>E</fname>
</parent>
<parent>
<fname>F</fname>
</parent>
</root>
Callout Service 2:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ServiceCallout async="false" continueOnError="false" enabled="true" name="callout_service_2">
<DisplayName>callout_service_2</DisplayName>
<Properties/>
<Request clearPayload="true" variable="myRequest">
<IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
</Request>
<Response>calloutResponse_2</Response>
<HTTPTargetConnection>
<Properties/>
<URL>https://localhost:8080/getService2</URL>
</HTTPTargetConnection>
</ServiceCallout>
Extract Variables 2:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ExtractVariables async="false" continueOnError="false" enabled="true" name="extract_service_2">
<DisplayName>extract_service_2</DisplayName>
<Properties/>
<Source clearPayload="false">calloutResponse_2</Source>
<VariablePrefix>detailResponse1</VariablePrefix>
<XMLPayload stopPayloadProcessing="false">
<Variable name="parent" type="nodeset">
<XPath>//root/parent</XPath>
</Variable>
</XMLPayload>
</ExtractVariables>
I’m trying to achieve the below output:
<root>
<parent>
<fname>A</fname>
</parent>
<parent>
<fname>B</fname>
</parent>
<parent>
<fname>C</fname>
</parent>
<parent>
<fname>D</fname>
</parent>
<parent>
<fname>E</fname>
</parent>
<parent>
<fname>F</fname>
</parent>
</root>
When I hit the URL and trace the request, the value of the variable parent from Extract Variables 1 is getting overridden by Extract Variables 2 as the key is same in both the cases.
I’ve tried using property but unable to get the response assign to it. I’ve already raised a ticket on it ref: Facing problem in assigning response from xml payload to variablePrefix.
I tried combining the response using javascript using “+” operator but got an error as below:
This page contains the following errors:
error on line 7 at column 9: Extra content at the end of the document
Below is a rendering of the page up to the first error.
An invalid XML is formed.
Please help me out with this.