Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Answered

Send xml to an external web service. AX2009

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.

  • bperez Profile Picture
    bperez 5 on at
    RE: Send xml to an external web service. AX2009

    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.

  • Verified answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: Send xml to an external web service. AX2009

    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.

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: Send xml to an external web service. AX2009

    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)

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans