How to drop empty SOAP-Body elements in REST-SOAP-REST proxy

I created a REST - SOAP - REST proxy in Edge. Input is application/json via POST.

lets say json input is

{ “A”: { “B”: { “C”: “D”, “E”: “F” } } }

this gets converted to soap internally via json payload extract and build soap policy to

soapenv:Envelopesoapenv:BodyDF</soapenv:Body></soapenv:Envelope>

this is fine and works. But when i have scenarios like this

json input is

{ “A”: { “B”: { “E”: “F” } } }

this gets converted to soap internally via json payload extract and build soap policy to

soapenv:Envelopesoapenv:BodyF</soapenv:Body></soapenv:Envelope>

Iam getting error from target where C is rejected. Would do u suggest to remove C if empty.

Target is fine as long as there are no empty elements. For ex: in the above case ,

soapenv:Envelopesoapenv:BodyF</soapenv:Body>

</soapenv:Envelope>

C is an example element. There are 10s of elements like these and could be very random as many are optional elements.

There is a XSLT here (https://stackoverflow.com/questions/6648679/removing-empty-tags-from-xml-via-xslt) that removes empty tags. I would add that XSLT after the assign message policy.

1 Like

Worked great ! Just added a Javascript policy after xsl and overwrote request.content.

Thanks for the help !