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 :
Microsoft Dynamics AX (Archived)

AX 2009 AIF

(0) ShareShare
ReportReport
Posted on by 75

Hi all,

I am a .NET developer who is working in AX 2009 writing some AIF Custom web services. The intention of the AIF services is to replace some obsolete code written against the Business Connector. Plus the AIF looks like a good long term option.

After struggling with a number of issues for a while now, I am of the opinion that the AIF in 2009 is very underdeveloped and difficult to use. The main issues are around no inbuilt support for de/serialization, and especially the lack of schema generation. Does this seem fair? The situation looks much better in AX2012 but that isn't an option.

Having to write my own schemas is a real problem. It seemed possible until I added a second service method that returns the same types - in the client, updating the service reference then resulted in a lot of duplicate service classes (because the WSDL has duplicate definitions from the two methods). I am writing my own code to try and work around this, but as I have no control over the way getSchema() is called during service generation, it's fairly tricky.

If anyone's aware of any utilities or libraries I would really appreciate a link! There is some really useful code here, and I'm using the de/serialize code but the schema generation isn't quite right.

*This post is locked for comments

I have the same question (0)
  • Martin Dráb Profile Picture
    237,959 Most Valuable Professional on at

    getSchema() seems to suggest that you're talking about document service, but they are all about serialization. Could you please give me an example of the problem?

  • Paradroid Profile Picture
    75 on at

    It's not a document service, it's just a custom service - a class that calls existing code in x++ classes, exposed as an AIF service. When building the service, AX seems to scan every service operation, then for each input/output type it calls getSchema(). The problem with this is that in a scenario like this:

    CustomerService

    -void CreateCustomer(CreateCustomerRequest customer)

    -GetCustomerResponse GetCustomerByName(str name)

    (where both CreateCustomerRequest and GetCustomerResponse contain a Customer class)

    you get two definitions of Customer in the schema when calling the WSDL.

    In the .NET project I'm using to call AX, this creates two classes - CustomerService.Customer and CustomerService.Customer1, which causes lots of problems.

  • Martin Dráb Profile Picture
    237,959 Most Valuable Professional on at

    If you're talking about custom services, I must agree that they're not easily usable in AX 2009. It feels more like a research of what you can do with the infrastructure then real development. To be honest, I wouldn't invest my time into it, especially not in year 2015.

    You can provide your own schema for a type by override getSchema() and returning your schema from there. You'll find an example in Creating Custom Dynamics AX Services.

    It seems that your main problem is in returning the same type from several operations of the same service. If you want to continue dealing with it, can you tell us what exactly do you mean by "causes lots of problems"? Unfortunately I don't have any AX 2009 on-hand to check whether the generator can be modified.

  • Paradroid Profile Picture
    75 on at

    Thank you - what you said about custom services sounds exactly what I am experiencing. After reading a few 2012 articles it all looks much more complete in that version - and of course Microsoft are recommending the AIF as the sole integration option.

    My schema problem is that (doing as you suggested, overriding getSchema()), the generated WSDL includes two definitions of the same type. My .NET service reference is getting confused by this and generating two classes. The problems are that the code I use to map back to .NET types needs to be written for both Customer and Customer1!

    There is a workaround I think - create a dummy service operation that returns a dummy class. Within that class, implement getSchema() to return schemas for all the types shared between the service methods. Then, remove the duplicate schemas for each call. In theory this will work but I've not finished it yet.

    Would you recommend sticking with the BC for 2009 integration?

  • Verified answer
    Martin Dráb Profile Picture
    237,959 Most Valuable Professional on at

    I can't really tell you what to do, because I don't know your situation. If you have some solution based on BC and it works, I would simply let it be until upgrading to a new version of AX. But you might be forced to use web services anyway, depending on your requirements. For new development, using custom services may be an option, nevertheless I would at least consider the following approach:

    1. Create service and contract classes in the same way as you would do in AX 2012. They won't have attributes such as DataMemberAttribute, but the actual interface and implementation will be the same. Note that you won't create any kind of service in AX.
    2. Create a WCF service in Visual Studio, which will run on IIS. Create operations and types as you like and consume the service as usual. You might want to add CallContext parameter, to pass contextual data in the same way as in AX 2012. You won't get into any troubles with serialization or anything, because this is pure WCF.
    3. Let your WCF service call the service class in AX 2012 via BC.

    The disadvantage is that you have to maintain data contract classes and conversion between them. But when you upgrade to AX 2012, you'll simply expose the service class in AX 2012, connect consuming applications to this service and drop the WCF service created in point 2. It should be pretty easy.

  • Paradroid Profile Picture
    75 on at

    That's a good idea thanks. I am more or less at a point where I need to walk away from trying to use the AIF due to difficulties generating complex schemas.

    Building a set of WCF services that use the BC internally does sound like the best approach for 2009, and like you say if a 2012 upgrade can be done then the WCF part will be obsolete.

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans