Parsing MTOM XML response body from a SOAP service in API Management policy

Michał Szymczak 0 Reputation points
2024-12-06T08:31:24.9033333+00:00

Hi, I'm trying to convert SOAP to REST and expose it via the API Management service.

Generated code is fine. I made small tweaks for adjusting the backend server required request headers.

I get a proper backed response with code 200 and body in Content-Type "application/xop+xml". Response body below and exception details from Azure logger are below.

--uuid:c40e7521-4805-4825-b5dd-76cbc845a5b7+id=8574330
Content-ID: <http://tempuri.org/0>
Content-Transfer-Encoding: 8bit
Content-Type: application/xop+xml;charset=utf-8;type="application/soap+xml"

<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing"><s:Header><a:Action s:mustUnderstand="1">http://CIS/BIR/PUBL/2014/07/IUslugaBIRzewnPubl/ZalogujResponse</a:Action></s:Header><s:Body><ZalogujResponse xmlns="http://CIS/BIR/PUBL/2014/07"><ZalogujResult>some_token</ZalogujResult></ZalogujResponse></s:Body></s:Envelope>
--uuid:c40e7521-4805-4825-b5dd-76cbc845a5b7+id=8574330--


Exception

[{"severityLevel":"Error","outerId":"0","message":"Invalid XML message","type":"GatewayError","id":"0","parsedStack":[{"method":"set-body","level":0,"line":0}]}]

Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
2,239 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Vahid Ghafarpour 22,290 Reputation points
    2024-12-25T19:39:19.58+00:00

    It looks like you're getting a GatewayError due to an "Invalid XML message" when your SOAP response is in application/xop+xml format. Ensure that the XML format is valid and well-formed. You can use an XML validator tool to check for any errors or inconsistencies in the XML structure.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.