You're almost there! Please answer a few more questions for access to the Applications content. Complete registration
Interested in joining? Complete your registration by providing Areas of Interest here. Register

Condition in REST to SOAP policy

Accepted answer
28
Views
2
Comments
edited May 6, 2021 3:49PM in API Management 2 comments

Content

Hi gurus,

One of our APIs needs to have a REST to SOAP policy.
The JSON we are sending as a Request might have some null values. i.e.:
{
    "Tag1": null,
    "Tag2": "test",
    "Tag3": 100
}

So we get an error in the REST to SOAP conversion when trying to construct the xml Tag1

<Envelope xmlns="http://www.w3.org/2003/05/soap-envelope"&gt;
   <Body>
        <Tag1 xmlns="http://namespace">${payload.Tag1}</Tag1&gt;
        <Tag2 xmlns="http://namespace">${payload.Tag2}</Tag2&gt;
        <Tag3 xmlns="http://namespace">${payload.Tag3}</Tag3&gt;
   </Body>
</Envelope>

Is there a way to add conditional logic in this policy to evaluate the value of a payload tag or do we need to do this validation in a groovy policy previous to this step?

Tagged:

Howdy, Stranger!

Log In

To view full details, sign in.

Register

Don't have an account? Click here to get started!