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, August 10, 2011

Microsoft Dynamics AX 2012 - A Dive into Services, Custom Services (Part I)

Recently I have been doing a dive into all the services, and service design within Microsoft Dynamics AX 2012. I started with a dive into services, and from there covered systems services, with a focus on the Metadata Service, and followed with a look at Document Services.

I continue my series, with this post, focusing on Custom Services. This is actually pretty new for AX, and has a lot of great possibilities when it comes to exposing business logic, that can be used within and externally of Microsoft Dynamics AX 2012.

Now let me state, that the intent of custom services is to represent simple DataContracts, and custom business logic. For any complex data entity needs, Document Services is the right path.

It's not to say the custom services, and document services can't be used together, in a scope of work. Encapsulated, and combine to offer abstraction --- were such concepts make sense. However the point to not be taking lightly. The reality of this goes back to what I was trying to point out, in my recent article on Just because you can, doesn't mean you should.

With that aside, lets look at the make up of a custom service example. To start, a custom service itself, is made up of three things.: X++ Class, with one-to-many SysEntryPointAttribute tagged methods,a Service Node with operations representing the given SysEntryPointAttribute tagged methods and finally a Service Group in which the Service Node is a part of and deployed ready for consumption.

Now, lets take a look at the class object in a little more detail, since this is where we start with custom services. With this class, one thing that is important to point out is the fact that this should have it's property of RunOn set to Server.

Doing this makes sure the scope of execution for the given entry points are actually set correctly. This is a must, since this code will be running on the server.

Moving from there, lets take a look at what a given SysEntryPointAttribute, metadata tagged method looks like.

The above is a really simple method, is simply takes a string parameter, and then combines that and returns back a string. The point to see here is the tag area, in which we tell AX 2012 that this is a Service Operation through the use of the SysEntryPointAttribute metadata tag.

From here, now we can move on to the service node, set it's properties to point to our given custom class, so we can see what operations we can make use of.

Now that we have set this, we can go back to the Operations for the given service, right click, and then left click on add operation.

If we now take and select to add the getHello operation from the list, and click add, we will then see this now show up under the possible operations for use with the given custom service.

Now that we have this service operation to make use of, we can add this service to our given custom service group, publish it, and then make use of it from within AX 2012 or outside of AX 2012.

Now with this, we see simply and quickly we can get a custom service up and running, with really little effort. It's all about the metadata Attributes that now exists in Microsoft Dynamics AX 2012 that enables this whole framework to take place.

For now that it's on the topic. I'm doing this part of dive into services as a series. There is a lot to cover in this area, with a lot being very, very new, so I want to make sure and have this broken into easily managed post. I will be linking back to this post, with Part II, when we dive into the use of DataContracts.

That's all for now, but check back soon as more to come! Till next time!

"Visit the Dynamics AX Community Page today!"

Labels: , , , , , , ,


Post a Comment

<< Home

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