码迷,mamicode.com
首页 > 其他好文 > 详细

外部系统调用AX服务

时间:2015-12-30 19:25:20      阅读:163      评论:0      收藏:0      [点我收藏+]

标签:

1 外部系统调用AX Customer Service,默认是已当前域用户访问AX。

2 如果要模拟其他用户,可以使用CallContext 对象。

3 模拟其他用户,必须使用Business Connector的用户来执行程序,否则会报错"Unable to logon On Microsoft Dynamics"

4 可以在AX中创建"声明用户",并用Business Connector账号模拟登陆

 

实例代码:

void callCustomerService()
{
string response;
JAY_GreetingsClient client = new JAY_GreetingsClient();
try
{
CallContext context = new CallContext();
context.Company = "TPS";
context.LogonAsUser = "outcompany.com\\OutUser001";
//context.LogonAsUser = "tpsax.com\\houzejing";
context.Language = "en-us";
response = client.helloName(context, "xiangliqi");
Console.WriteLine(response);
Console.Read();
}
catch (Exception e)
{
Console.WriteLine(e.Message);
Console.Read();
client.Abort();
}
client.Close();
}

void callUserSessionService()
{
AX.UserSession.UserSessionInfo userSessionInfo;
AX.UserSession.UserSessionServiceClient client = new AX.UserSession.UserSessionServiceClient();
try
{
AX.UserSession.CallContext context = new AX.UserSession.CallContext();
context.Company = "TPS";
context.LogonAsUser = "tpsax.com\\houzejing";
context.LogonAsUser = "outcompany.com\\OutUser001";
context.Language = "en-us";

userSessionInfo = client.GetUserSessionInfo(context);
Console.WriteLine(userSessionInfo.UserId);
Console.WriteLine(userSessionInfo.Company);
Console.Read();
}
catch (Exception e)
{
Console.WriteLine(e.Message);
Console.Read();
client.Abort();
}
client.Close();
}

外部系统调用AX服务

标签:

原文地址:http://www.cnblogs.com/xiangliqi/p/5089489.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!