0

I want to change the output format of the soap response, before passing it onto the client. I am using the soap pass-through as specified in the documentation https://azure.microsoft.com/en-ca/blog/soap-pass-through/

Soap service used in this example is hosted at https://fazioapisoap.azurewebsites.net/FazioService.svc?singleWsdl

I am unable to extract the soap response in the liquid template. Soap response does get generated, however, there is no data.

enter image description here

Is there anything wrong with this code?

<policies>
    <inbound>
        <set-header name="Content-Type" exists-action="override">
            <value>text/xml</value>
        </set-header>
        <set-body template="liquid">
            <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
                <soapenv:Header />
                <soapenv:Body>
                    <tem:GetOpenOrders>
                        <!--Optional:-->
                        <tem:cust>{{body.Envelope.Body.GetOpenOrders.cust}}</tem:cust>
                    </tem:GetOpenOrders>
                </soapenv:Body>
            </soapenv:Envelope>
        </set-body>
        <base />
    </inbound>
    <backend>
        <base />
    </backend>
    <outbound>
        <set-body template="liquid">
            <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
                <s:Body>
                    <GetOpenOrdersResponse xmlns="http://tempuri.org/">
                        <GetOpenOrdersResult xmlns:a="http://schemas.datacontract.org/2004/07/FazioAPISoap" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">                        
  {% for summary in body.Envelope.Body.GetOpenOrdersResponse.GetOpenOrdersResult.OrderSummary -%}
    <a:OrderSummary><a:order_id>{{summary.order_id}}</a:order_id></a:OrderSummary>
  {% endfor -%}
     </GetOpenOrdersResult>
                    </GetOpenOrdersResponse>
                </s:Body>
            </s:Envelope>
        </set-body>
        <set-header name="Content-Type" exists-action="override">
            <value>text/xml</value>
        </set-header>
        <base />
    </outbound>
    <on-error>
        <base />
    </on-error>
</policies>
Nishank
  • 159
  • 1
  • 11
  • is it because of namespace prefix before each element, I cannot access this value? ` false Things 10001 ` – Nishank Aug 12 '20 at 18:33

1 Answers1

0

You don't have to prefix the namespaces. This requests is valid

<set-body template="liquid">
    <Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
        <Body>
            <GetOpenOrdersResponse xmlns="http://tempuri.org/">
                <GetOpenOrdersResult xmlns:a="http://schemas.datacontract.org/2004/07/FazioAPISoap" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">                        
  {% for summary in body.Envelope.Body.GetOpenOrdersResponse.GetOpenOrdersResult.OrderSummary -%}
                    <OrderSummary>
                        <order_id>
                            {{summary.order_id}}
                        </order_id>
                    </OrderSummary>
  {% endfor -%}
                </GetOpenOrdersResult>
            </GetOpenOrdersResponse>
        </s:Body>
    </s:Envelope>
</set-body>

I can see two potential problems with your request.

  1. You might be missing SOAPAction header, example for submitOrder
<set-header name="SOAPAction" exists-action="override">
    <value>http://tempuri.org/IFazioService/submitOrder</value>
</set-header>
  1. Also you may want to set backend url and rewrite path to the resource (if APIM path is different than the SOAP service)
<set-backend-service base-url="{{s-iserve-store-inventory-backend-url}}" />
<rewrite-uri template="?" copy-unmatched-params="false" />
lukaszberwid
  • 1,097
  • 7
  • 19