4

Right now i am exposing services from AX 2012, how to configure it to expose it as REST?

I have to use this service in MAC Xcode for IOS integration, I believe its easy if it is a REST than SOAP.

Kenny Saelen
  • 894
  • 1
  • 5
  • 16

1 Answers1

6

Well, there is an interesting question but with no straightforward answer :(

I would say there is no easy and simple way of exposing your Ax WCF service as REST, but there are workarounds. Here is what I would do.

You can create your own ASP.NET WebAPI project which can be hosted on an IIS or self hosted in service or executable is also possible. (WebAPI website and tutorial to create a simple WebAPI project). This WebAPI project is actually using ASP.NET MVC 4.0 so you can create controllers to contain the logic to fetch data.

In the tutorial they are loading products and in the controller an array is used for demo purposes.

Product[] products = new Product[] 
    { 
        new Product { Id = 1, Name = "Tomato Soup", Category = "Groceries", Price = 1 }, 
        new Product { Id = 2, Name = "Yo-yo", Category = "Toys", Price = 3.75M }, 
        new Product { Id = 3, Name = "Hammer", Category = "Hardware", Price = 16.99M } 
    };

Well, now what you can do is replace this by a service call to your Ax WCF service. By doing this, outside users can actually do HTTP requests to your WebAPI site and WebAPI will handle all of the routing for you and will return the JSON format.

For example:

  • "http://localhost:xxxx/api/products/1"
  • "http://localhost:xxxx/api/products?category=hardware"

And in the background, the controller itself can do service calls to Ax using the SOAP way with WCF.

Kenny Saelen
  • 894
  • 1
  • 5
  • 16