Creating custom service in AX 2012

2nd class should look like this ->
Step 1:
Create two classes in AX. One class should
instantiate other class as follows:
1st class should like this ->
Step 2:
Right click “Services”node and click New
Service.
Add the service as below:
Assign a service name and assign Calling
class in Step 1 as Class field value in properties window.
Right click Operation node and click “Add
Operation”, this will automatically show the methods under that class. Click on
the “Add” tick box field in each method to publish them into service.
Step 3
Right click “ServiceGroups” node and click
New -> Service Group.
Add the service as below:
Drag and drop the Service created in Step 2
under this group node. Right Click on the service group node and
select “Deploy Service Group”. This should show a success infolog like
this :
Step 4
Open Inbound Port list form and check if
the newly deployed service is added there with state Active.
Copy the WSDL URI, which is this in my
case:
Step 5
In VS 2010, create a new project of type
Console Application. Add the Service Reference (WSDL URI) and write the code
like below to consume the web service hosted by AX.
using System;
using
System.Collections.Generic;
using System.Linq;
using System.Text;
using
SUV_AX2012_ConsoleAppl_CustNameDemo.SUV_CustNameDemoGroup;
namespace
SUV_AX2012_ConsoleAppl_CustNameDemo
{
class Program
{
static void Main(string[]
args)
{
SUV_CustNameDemoClient
Client = new SUV_CustNameDemoClient();
string
CustName = Client.getCustName(null);
Console.WriteLine(CustName);
Console.ReadLine();
}
}
No comments:
Post a Comment