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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Send xml to an external web service. AX2009

(0) ShareShare
ReportReport
Posted on by 5

I have an external web service that asks for an XmlNode as a parameter, and returns another XmlNode.

I tried this code:

{ 
    ReferenceWebService.SoapClient soapWS;
    
    xmldocument doc;
    XmlNode xml;
    XmlNode xmlResult;
    ;
    doc = new xmldocument();
    doc.load(_Path   _xmlFile);
    xml = doc.documentElement();
    
    try
    {
        new InteropPermission(InteropKind::ClrInterop).assert();
        
        soapWS = new ReferenciaWebService.SoapClient("endPointName");
        xmlResult = soapWS.recordService(xml); //definition: XmlNode recordService(XmlNode docIn)
        
        CodeAccessPermission::revertAssert();
    }
    catch(Exception)
    {
        [...]
    }
    return xmlResult;
}

When i compile i get this error in the line 17: "The argument '1' is incompatible with the necessary type."

So, How can I send that .xml?

The service works with other functions that ask for other parameters, but with the functions that ask for XmlNode I have this problem.

I also tested the web service outside Ax, for example, the SoapUI application or a console app in c #, created by me, and all functions work correctly.

I have looked for examples of web services from AX, but I didn't find any with xml, nor the same problem in any forum.

Thanks for your help.

I have the same question (0)
  • Suggested answer
    nmaenpaa Profile Picture
    101,162 Moderator on at

    I'm quite sure that the external web service doesn't want x++ object of type "XmlNode" as a parameter.

    If you succesfully called it from C# and passed XmlNode as parameter then it seems that you should provide such object instead of x++ XmlNode (which are two completely different things). Normally you can't handle such scenario directly from x++, so you should develop a web service client with C#, and use it from x++.

    Please check the documentation: docs.microsoft.com/.../cc654149(v=ax.50)

  • Verified answer
    nmaenpaa Profile Picture
    101,162 Moderator on at

    Sorry, actually the doc above doesn't contain instructions for your specific scenario. Anyway the technical requirement is that you need to pass objects in the web service instead of primitive types (I assume the other web services that you mention are using primitive types such as str).

    Anyway you need to find a way to create a C# XmlNode object and pass that to the service. Then it will work.

  • bperez Profile Picture
    5 on at

    Thanks for your answer, I thought about that, but I wanted to check if I was doing something wrong, before I had to leave AX.

    Finally what I did, I don't know if I did it in the best way, but it works, I created a library in c # that asks for the path of xml file, it calls the web service and converts the XmlNode response to a string. Then, in AX I reference the .dll and convert the string that returns to xml in X++  so I can work with it.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 449 Super User 2025 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 422 Most Valuable Professional

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans