Custon SOAP header and body (and using CDATA tag)

0
We are trying to communicate with a webservice that needs it's communication is a specific way. The message should look like this: <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:inb="https://someurl.nl"> <soapenv:Header> <authenticate> <guid> ...... </guid> <username> .... </username> <password> ..... </password> </authenticate> </soapenv:Header> <soapenv:Body> <inb:inboxbericht> <inb:message> <![CDATA[ ]]> </inb:message> </inb:inboxbericht> </soapenv:Body> </soapenv:Envelope> So I used the custom header and body option which looks like this: Header part <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:inb="https://someurl.nl"> <soapenv:Header> <authenticate> <guid>{2}</guid> <username>{3}</username> <password>{4}</password> </authenticate> </soapenv:Header> Body part: <soapenv:Body> <inb:inboxbericht> <inb:message> <![CDATA[ {1} ]]> </inb:message> </inb:inboxbericht> </soapenv:Body> </soapenv:Envelope> The problem is that Mendix throws errors when calling the webservice (see the stacktrace below). It seems that since the soapenv:Envelope is opened in the header and </soapenv:Envelope>  is closed in the body that Mendix does not like this. But I wonder if that is the real problem. Combining the two in a seperate string produces a correct string and when it is given to the XML parser on the other side the string is processed normally. So it seems that the string I am building is OK. But why does the webservice action does not like the header and body? And is there a workaround? Regards, Ronald [EDIT] The problem seems to be that Mendix does not support the CData tag. For a simple request is does not escape the message while when using custom body it does escape the message and thus the request fails. Some post about CDATA https://community.mendix.com/link/questions/7350 https://community.mendix.com/link/questions/86250 The Core.callWebservice is deprecated. I tried to use that one but am getting bad request errors so I must be doing something wrong here.
asked
3 answers
0

It's not pretty but when I faced a similar challenge I built the XML string in Mx as a variable and then passed that to java to trigger the Mx core web service function which in turn did not complain about my "custom" XML.

Hope it helps, if you want the piece of code just let me know (I'd have to look it up on an older project).

answered
0

Have you tried leaving all the soapenv nodes out? Mendix takes care of those nodes.

So the header part becomes:

<authenticate>
  <guid>{2}</guid>  
  <username>{3}</username>
  <password>{4}</password>
</authenticate>

And the body part:

<inb:inboxbericht>
  <inb:message>
    <![CDATA[
{1}
]]>
  </inb:message>
</inb:inboxbericht>

 

 

answered
0

You could also  try to build a domain to xml mapping, map that to a string and insert that string to your message.

answered