0
votes

I have a SOAP service where I need to add one property to the XML Body prior to sending the request onto the backend service.

My Postman request is as below:

<?xml version="1.0" encoding="utf-8"?>
<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
  <Body>
    <gprnEnquiry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.somedomain.com">
      <gprn>123456</gprn>
      <registrationstatus>registrationstatus1</registrationstatus>
    </gprnEnquiry>
  </Body>
</Envelope>

I am passing in a Content-Type header of text/xml

My APIM Inbound policy is as below:

    <set-body template="liquid">
        <Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
            <Body>
                <gprnEnquiry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.somedomain.com">
                    <gprn>{{body.gprnEnquiry.gprn}}</gprn>
                    <registrationstatus>{{body.gprnEnquiry.registrationstatus}}</registrationstatus>
                    <authKey>{{My-NamedValue}}</authKey>
                </gprnEnquiry>
            </Body>
        </Envelope>
    </set-body>

From enabling Request and response body capture in APIM I can see that the values from the request are coming in and the response is going out with no value.

Backend request

<Envelope
    xmlns="http://schemas.xmlsoap.org/soap/envelope/">
    <Body>
        <gprnEnquiry
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xmlns="http://www.somedomain.com">
            <gprn></gprn>
            <registrationstatus></registrationstatus>
            <authKey>xxxxxxxxxxx</authKey>
        </gprnEnquiry>
    </Body>
</Envelope>

Anyone have an idea why the values from the source request are not being mapped through to the back end request?

1

1 Answers

0
votes

OK the answer here was due to the format of the request body and how the APIM policy maps elements. By including the <?xml> and Envelope nodes within the request prevents the Liquid Template from correct mapping the values.

Also APIM does not allow you to specific that the Envelope is within the request body such as {{envelope.body.gprnEnquiry.gprn}}.

Changing the request body to the below resolved the issue:

  <Body>
    <gprnEnquiry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.somedomain.com">
      <gprn>123456</gprn>
      <registrationstatus></registrationstatus>
    </gprnEnquiry>
  </Body>