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

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

How do I push an XML to external webservice using AIF in AX2012?

(0) ShareShare
ReportReport
Posted on by 110

I need to integrate AX2012 with a custom interface that acts as middleware between AX and their WMS. The need is for various documents to be pushed to an external  webservice.

I was hoping to do this through AIF by setting up an outbound port which pointed to a Webservice.

Is this possible to do or what other options do I have?

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Rene Volkmer Profile Picture
    326 on at
    RE: How do I push an XML to external webservice using AIF in AX2012?

    Hi Amghild, you can send AIF document (XML formatted according external ws needs) via HTTP outbound adapter (i.e. https://blogs.msdn.microsoft.com/dynamics-coe/2015/02/19/outbound-http-adapter-for-aif-in-dynamics-ax-2012), that is basically external webservice calling.

    Best regards

    Rene 

  • Melvin Steenkamp Profile Picture
    65 on at
    RE: How do I push an XML to external webservice using AIF in AX2012?

    Hi,

    Could you give me code examples of this.

    Regards

  • Mikko Profile Picture
    445 on at
    RE: How do I push an XML to external webservice using AIF in AX2012?

    Thanks a lot! I'll let you know later if I had to do something differently.

  • Anghild Profile Picture
    110 on at
    RE: How do I push an XML to external webservice using AIF in AX2012?

    Hi Mikko, yes I have.

    The process was a little involved but I'll outline the main steps below to point you in the right direction.

    What I had to do is the following:

    1. Create a service reference for the Web Service in Visual Studio and add it to AX. See the link posted by Martin above.

    2. Create your own AIF Adapter in AX. For this part I copied and modified one of the existing classes. Have a look at AIFWcfAdapter and AIFWcfSendAdapter for reference. Make sure that AIFMyAdapter.getSendAdapter() returns AIFMySendAdapter(). Change AIFMySendAdapter.sendMessage() accordingly.

    As an example, something like this:

    public void sendMessage(AifGatewayMessage gatewayMessage)

    {

       // Variable for service client type.

       MY.ServiceReference.WMS.OutboundClient outboundClient;

       // Variable for the service client.

       ClrObject clientType;

       //.Net exception handler

       System.Exception ex;

       //XML String handler

       System.String xml;    ;

       //Check for adapter

       if (!adapterIntialized)

           throw error("@SYS95134");

       try

       {

           //Get interop permission

           new InteropPermission(InteropKind::ClrInterop).assert();

           //ReadXMMessage

           xml = gatewayMessage.parmMessageXml();

           clientType = CLRInterop::getType("MY.ServiceReference.WMS.OutboundClient");

           outboundClient = AifUtil::createServiceClient(clientType);

           outboundClient.ShipmentCreateTXT(xml);

           break;

       }

       catch(Exception::CLRError)

       {

           // Handle the exception and display message in the InfoLog.

           ex = CLRInterop::getLastException();

       }

    }

    3. Register your adapter. You can do this in a job. Google for more info but it should be something like this:

    static void STX_RegisterAdapters()

    {

       AifAdapter AifAdapter;

       ;

       aifAdapter::registerAdapters();

    }

    4. You should now see your adapter in the outbound adapter list when creating an outbound port. Select a service operation and you should be good to go. It should work with the standard out of the box services.

    5. If you want to send picklists for example, you can add a snippet like this to \Classes\SalesPickingListJournalPost.endPost()

    if (wmsPickingRoute.canXMLBeSent())

       {

           wmsPickingRoute.sendElectronically(XMLDocPurpose::Original);

       }

    Not sure if I listed all the steps, but this should put you on the right track at least.

    Good luck.

  • Mikko Profile Picture
    445 on at
    RE: How do I push an XML to external webservice using AIF in AX2012?

    Hi  Anghild,

    I need to do excatly the same thing. Have you made it work?

  • Anghild Profile Picture
    110 on at
    RE: How do I push an XML to external webservice using AIF in AX2012?

    The assumption is correct, however, I don't want to submit a file to the file system first. It needs to be submitted directly to the external web service. For that I'll need to create a custom outbound adapter like Martin mentioned below.

  • Anghild Profile Picture
    110 on at
    RE: How do I push an XML to external webservice using AIF in AX2012?

    Thank you for the info Martin. This is exactly what I need to do.

    I've managed to consume the external web service and submit a file to it. I assume the next step is to create a class that implements AifIntegrationAdapter and register it as a port.

    Do you perhaps have a .xpo which I can look at to use as an example?

  • Verified answer
    Martin Dráb Profile Picture
    236,182 Most Valuable Professional on at
    RE: How do I push an XML to external webservice using AIF in AX2012?

    Follow Consuming External Web Services [AX 2012] to understand how to call external services. The process creates a strongly-typed service client that can be used for calling that particular service. You can create a custom outbound AIF adapter that will use the service client.

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: How do I push an XML to external webservice using AIF in AX2012?

    As I can understand your requirement...

    You have external web service which requires XML in its format and you want AX 2012 to generate those xml for external web service

    If my understanding about your requirement is correct then,

    as per my knowledge.. yes it possible in AX to have this implemented using AIF

    You need to develop a custom service, and using this custom service you need to open a file adaptor outbound port, which will create required XML file for third party Web service

    Please verify following link for more details how to create Custom document web service in Dynamics AX 2012

    technet.microsoft.com/.../hh509053.aspx

    please verify, and appreciated if you update with your findings

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Community Member Profile Picture

Community Member 2

#1
Martin Dráb Profile Picture

Martin Dráb 2 Most Valuable Professional

#1
Guy Terry Profile Picture

Guy Terry 2 Moderator

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans