Announcements
We have an AX customization that requests and returns freight quotes to our carriers using XML documents. I need to modify this system for a new carrier that uses the SOAP protocol and web services. I have successfully programmed AX to send the web request and parse the response using a sample XML file. Now I am trying to create the XML document within AX2009, and am having trouble getting the SOAP envelope formatted correctly. I will admit here, that I am not familiar with SOAP at all. To me, it looks like a specifically formatted XML document that the XML Document class should be able to create. If it isn't, please steer me in the right direction.
The soap request needs to be formatted as shown below. Notice that there are two namespaces defined on the soapenv:Envelope node. That is the portion that I can't figure out how to generate.
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="schemas.xmlsoap.org/.../envelope xmlns:myr="http://myurl.com/" >
<soapenv:Header/>
<soapenv:Body>
<myr:takeSomeAction>
<node1>?</node1>
</myr:takeSomeAction>
</soapenv:Body>
</soapenv:Envelope>
This is the code I have tried..
xmlDoc = XmlDocument::newBlank("UTF-8");
envelopeNameSpace = 'schemas.xmlsoap.org/.../envelope';
rateNameSpace = 'http://myRate.ws.odfl.com/';
soapEnvelope = xmlDoc.appendChild(xmlDoc.createElement3('soapenv','Envelope',envelopeNamespace));
soapHeader = soapEnvelope.appendChild(xmlDoc.createElement3('soapenv','Header', envelopeNamespace));
soapBody = soapEnvelope.appendChild(xmlDoc.createelement3('soapenv','Body', envelopeNamespace));
MyRateRequest = soapBody.appendChild(xmlDoc.createElement3('myr','GetLTLRateEstimate', rateNameSpace));
*This post is locked for comments
There may be no reason at all, except that we haven't, up to now needed to. For this task, I used the XMLDocument class to create the SOAP request so that I could make as few changes as possible to the existing code. The other carriers don't use web services, so the majority of the customization still functions as originally designed by our reseller.
That's a lot of code. Any particular reason you couldn't use the "service reference" feature in the AOT?
Solved! The server error was not caused by the soap envelope. Even though my document is formatted differently, the request works correctly.
André Arnaud de Cal...
293,304
Super User 2025 Season 1
Martin Dráb
232,160
Most Valuable Professional
nmaenpaa
101,156
Moderator