SOAP Request parsing

hello, I figured out how to make a SOAP request use WEB REQUEST.

Basically the request looks like this:

    POST https://api.nmbrs.nl/soap/v3/DebtorService.asmx
Content-Type: text/xml; charset=utf-8

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:deb="https://api.nmbrs.nl/soap/v3/DebtorService">
   <soapenv:Header>
      <deb:AuthHeader>
         <!--Optional:-->
         <deb:Username>test@test.nl</deb:Username>
         <!--Optional:-->
         <deb:Token>22480ss---TOKEN---ce0362332</deb:Token>
      </deb:AuthHeader>
   </soapenv:Header>
   <soapenv:Body>
      <deb:Environment_Get/>
   </soapenv:Body>
</soapenv:Envelope>

I get a successful response:

HTTP/1.1 200 OK
Connection: keep-alive
Vary: Accept-Encoding
X-StackifyID: V2|b443151e-293a-4851-8ae7-8b3ffc176180|C58906|CD6136
Request-Context: appId=cid-v1:871556b2-6f80-431b-8398-4616f3f189cc
Access-Control-Expose-Headers: Request-Context
X-Frame-Options: DENY
Cache-Control: max-age=0, private
Date: Mon, 21 Dec 2020 11:02:01 GMT
Server: Microsoft-IIS/10.0
X-Powered-By: ASP.NET
Content-Type: text/xml; charset=utf-8

<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><Environment_GetResponse xmlns="https://api.nmbrs.nl/soap/v3/DebtorService"><Environment_GetResult><Domain>testoffice.nl</Domain><SubDomain>testoffice</SubDomain></Environment_GetResult></Environment_GetResponse></soap:Body></soap:Envelope>

However, when I try to parse the XML, I see that only the soap:Envelope gets parsed. the soap:Body is not parsed, and stays empty. But the Body is exactly what I need…

Any idea what I am missing here?

Hello @ArendP,

The Environment_GetResponse element in your XML has a default namespace declaration. EasyMorph can’t process non-root elements with a default namespace declaration and ignores such elements and all their child elements. A corresponding warning is issued when some elements were ignored.

As a workaround, you can try to remove the default namespace declaration from the Environment_GetResponse element with the “Modify column” action and the following expression:

replace([Column], 'Environment_GetResponse xmlns="https://api.nmbrs.nl/soap/v3/DebtorService"', 'Environment_GetResponse')

That worked, thanks!
I hope it’s a sustainable solution :slight_smile:

Sustainability of this workaround depends on the uniformity of the SOAP responses that you want to parse. But the workaround can be modified to handle a wider range of responses.

Fell free to post other types of SOAP responses to this topic and I will try to figure something out.