@Barahalikar Siddharth,
You state that the skipped json2xml policy shows the request header content type to be application/xml in the trace. In that case, should your Condition for executing the json2xml policy not be using “application/xml” rather than “text/xml”?
<Condition> (request.header.Content-Type = "application/xml")</Condition>
If not the above then I would redesign a little.
I would try adding an extract variables policy in the proxy request to capture the client’s requested content type as a variable. (Add the extract variables policy in the proxy request flow)
<ExtractVariables name='ExtractVariables.RequestedContentType'>
<Source>request</Source>
<Header name="Accept">
<Pattern ignoreCase="true">{contentType}</Pattern>
</Header>
<VariablePrefix>myproxyprefix</VariablePrefix>
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables
</ExtractVariables>
I’m making an assumption here that your proxy expects and receives an Accept header.
If you are relying on the Content-Type header because there’s no Accept header and the proxy request is a POST then amend the above from Accept to Content-Type.
You could then refer to this variable in the condition for the json2xml policy rather than the request.header (your code amended below, note that I use the single = as per @Anil Sagar’s answer)
<Step>
<Condition> (myproxyprefix.contentType = "text/xml")</Condition>
<Name>JSON2XML</Name>
</Step>
Although I don’t know the detail, I think you may want to think about your conversions. It seems odd that you are converting SOAP (XML) to json and then back to XML again should the client request it.
Assuming you won’t be returning the SOAP envelope to the client in either the JSON or the XML response, why not convert the SOAP target response into the XML format you require for the client and then send XML as the response by default?
Then, you would only need an xml2json conversion that would be for the case where the original request specified application/json.
This might simplify your flow conditions and remove some of the AssignMessage policies that are setting and resetting headers.