web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Create XMLDocument in AX

(0) ShareShare
ReportReport
Posted on by 201

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

I have the same question (0)
  • Verified answer
    lispyj Profile Picture
    201 on at

    Solved!  The server error was not caused by the soap envelope.  Even though my document is formatted differently, the request works correctly.

  • Suggested answer
    Joris dG Profile Picture
    17,782 on at

    That's a lot of code. Any particular reason you couldn't use the "service reference" feature in the AOT?

  • lispyj Profile Picture
    201 on at

    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.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans