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?

1 Like

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.

Hello @ArendP and @andrew.rybka thanks for this very useful thread. I also have to do a SOAP request.

I have to send the username/password every time I send an XML request in order to get a response from the API. Does the username/password necessarily have to be in the actual XML payload, or can we incorporate it as a “Username/Password” in the Authentication Settings of in the “Configure Connector” window (Connector Manager)?

image

Thanks,

Roberto

Hello Roberto,

The web location connector will not automatically add the specified credentials to the XML payload.

So if the SOAP service that you are connecting to requires the username/password to be present in the XML, you should add them by yourself.

1 Like

Hello,

Is it possible to generate a SOAP Request each a predefined period of time, f.e. each 5 minutes?

Thanks and regards,

Hi Jaime and welcome to the Community!

You can create an EasyMorph workflow that generates a SOAP request and schedule it to run every 5 minutes using either EasyMorph Launcher or EasyMorph Server. Read here for more details: EasyMorph | Scheduling workflows