Dynamics AX
  RSS Feed  LinkedIn  Twitter
Want to turn you're data into a true asset? Ready to break free from the report factory?
Ready to gain true insights that are action focused for truly data informed decisions?
Want to do all of this across mutliple companies, instances of Dynamics and your other investments?
Hillstar Business Intelligence is the answer then! (www.HillstarBI.com)

Hillstar Business Intelligence for Microsoft Dynamics AX and NAV on Mobile, Desktop, Tablet

Let us prove to you how we can take the complexity out of the schema and truly enable users to answer the needed questions to run your business! Visit Hillstar Business Solutions at: www.HillstarBI.com

Wednesday, February 17, 2010

Dynamics AX and WCF Service - Part II

Ok, so recently I wrote the following blog entry.: Dynamics AX 2009 - Service Reference to Custom WCF Service

In that post, I showed a custom Foo WCF Service, some ServiceContracts, OperationContracts and DataContracts. I also talked about how to reference this in Dynamics AX, make use of the objects, including how to make use of .Net List.

Now if we look at the Xpp Code, that I took a screen shot of, we can start our next post.:

So if you took exactly what I did and tried to implement it, you would get an error message inside Dynamics AX. A ClrError, stating the ClrObject could not be created.

The reason why is that the above screen shot, the code is executed where ran, which is typically the client.

Any Service Reference Xpp code, that calls a service reference at all, must be done at the Server Tier. This is actually well covered in a lot of different blog post, and something that most anyone that has done this kind of integration has ran into.

So this actually starts us into the next real section that I wanted to cover when working with WCF Services that one might create and want to work with from within a Dynamics AX implementation.

There are actually several different gotchas and points of interest someone would want to look for. So the following is an attempt to list those, and try to help out anyone going this route.

So one thing to note, is during the development of your custom WCF service or services, you will most likely be changing that code a good bit. It's always a good thing to create a console or windows form test project to make sure what your sending into the WCF is working and that the WCF code you wrote is working as expected.

The wonderful thing about such an approach you can catch unhandled exceptions during debug mode, where in Xpp this is not possible. You get a general message about the ExeceptionDetails is not serializable.

Now moving forward another note on developing WCF Services. Let say you have a good start, you make your reference in Dynamics AX, and start coding Xpp code. Then you realize another WCF OperationContract would be great. Go ahead and add that WCF OperationContract and make sure the Interface the Service makes use of, is updated correctly.

Then Go to the Service refernec in AX, right click, select regenerate, get the error messages, close the client, restart the AOS, and then restart the client. The new method should show up.

Only during this process, with the regenerate and restart of the AOS, does your WCF service change reflect in Dynamcis AX for use.

I will leave you here. There is actually some more points in this area. Also keep in mind with all these little gotchas, the flexbility offered with WCF Services is well worth the effort.

I plan on moving forward with more things to watch out for, and also why choose WCF Services over standard Web Services.

Thanks for reading, and check back soon!

"Visit the Dynamics AX Community Page today!"

Labels: , , , , , , , , ,


Anonymous Vladimir Senih said...


I like your posts about consuming WCF services very much. I've been working on this for a wile and I didn't find solution how to regenerate the service reference if I change something in WCF service without restarting the AOS. I work for company with 50 developers and it's really annoying that they must wait for AOS restart whenever I'm working with this kind of integration, so if there is a solution how to regenerate the reference without restarting AOS I would like to here it.


6:19 AM  
Anonymous Bjorn said...

Same situation for me. We used an old framework for our webservices, and we were exploring the possibilities of wcf in ax for our newest project, but the problem with the aos restarts and exceptions like faulted state that only got resolved by restarting the aos, makes us hesitate of using it.

4:20 AM  

Post a Comment

<< Home

Copyright 2005-2011, J. Brandon George - All rights Reserved