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

Announcements

No record found.

News and Announcements icon
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,166 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,166 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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

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

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 663

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 439 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 337 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans