Dynamics AX 2012-AIF使用C#访问

问题描述:

我可能错过了一些简单的东西,但我厌倦了与它战斗。似乎有很多连接库存AIF服务的例子,但我还没有找到一个简明的工作示例来连接到自定义服务。Dynamics AX 2012-AIF使用C#访问

假设如下:

Service reference configured in the project with a namespace of MyService 

That service has two methods exposed from Dynamics AX that we'll call: 
    helloWorld() and helloWorld2(str yourName) 

Each method returns a simple string 

你会用什么C#代码来调用每个方法和结果写入标签?

感谢您的帮助。

using [MyProjectName].MyService; 

...

MyServiceClient client = new MyServiceClient(); 
CallContext context = new CallContext(); 
label1.Text = client.helloWorld(context); 

MyServiceClient client = new MyServiceClient(); 
CallContext context = new CallContext(); 
label1.Text = client.helloWorld2(context, "test"); 

...