Struggling to integrate legacy SOAP-based services with modern RESTful APIs? This blog post explains exactly how you can streamline integrations by effectively adding and removing SOAP envelopes using Azure API Management.

Legacy systems often still rely heavily on SOAP protocols, especially in environments that previously used BizTalk. However, Azure Logic Apps primarily utilize RESTful interactions. Fortunately, Azure API Management provides a straightforward way to bridge this gap.

Why Use Azure API Management?

Azure API Management simplifies the handling of SOAP envelopes, making the integration of your legacy system significantly easier and more efficient. By manually managing SOAP envelopes, you can maintain consistent, RESTful Logic Apps and reduce complexity during migration processes.  Plus, all the work of adding and removing SOAP envelopes is handled in configuration inside API Management!  A huge win.

Key Benefits Highlighted:

  • Simplify SOAP-to-REST integration.
  • Manually handle SOAP envelopes for control and reliability.
  • Integrate legacy SOAP services easily with Azure Logic Apps.
  • Accelerate development by possibly reusing RESTful Logic App interfaces.
  • Ensure compatibility and smooth operation with legacy systems after migration.

Practical Steps Covered:

1. Configuring inbound policies to remove SOAP envelopes.

2. Setting outbound policies to add SOAP envelopes back for legacy systems.

3. Validating the results.

This approach enables applications to interact efficiently with legacy SOAP-based systems without compromising performance or flexibility.

 

APIM Inbound and Outbound Policy to Remove and Add SOAP Envelopes

<policies>
    <!-- Throttle, authorize, validate, cache, or transform the requests -->
    <inbound>
        <base />
        <set-body>@{
        // Parse the incoming SOAP message as XML
        var soap = context.Request.Body.As<XElement>();
        // Extract the contents of the <soap:Body> element
        var body = soap.Descendants().FirstOrDefault(e => e.Name.LocalName == "Body");
        // If a <Body> element was found, take its first child (the actual message payload)
        return body?.Elements().FirstOrDefault()?.ToString() ?? "";
    }</set-body>
        <set-backend-service base-url="https://las-yt-corefeatures.azurewebsites.net:443/api" />
        <rewrite-uri template="/SoapDemo/triggers/When_a_HTTP_request_is_received/invoke?api-version=2022-05-01&sp=%2Ftriggers%2FWhen_a_HTTP_request_is_received%2Frun&sv=1.0&sig=_ZSHT1ucOqsCD7OYiG51V9mKx42RqlRipqikKQ1stkY" />
    </inbound>
    <!-- Control if and how the requests are forwarded to services  -->
    <backend>
        <base />
    </backend>
    <!-- Customize the responses -->
    <outbound>
        <base />
        <set-body>@{
        var inner = context.Response.Body.As<string>();
        return "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
               "<soap:Header/>" +
               "<soap:Body>" +
               inner +
               "</soap:Body>" +
               "</soap:Envelope>";
    }</set-body>
    </outbound>
    <!-- Handle exceptions and customize error responses  -->
    <on-error>
        <base />
    </on-error>
</policies>

Conclusion

Using Azure API Management significantly simplifies your integration workflow, bridging the gap between old and new systems. It ensures that your migration to Azure Logic Apps is smooth, efficient, and reliable.

I would love to hear your experiences or questions! Leave a comment below with your thoughts or specific integration challenges you’ve faced.

Take a look at the YouTube video below for more details on this process.  

YouTube player

Watch for exciting content related to the Azure Integration Services, Azure Logic Apps, and Azure AI being created soon.

If you have any questions, feel free to reach out!