使用AIF Web服务连接到Microsoft Dynamics AX 2009

时间:2011-07-15 09:37:20

标签: wcf web-services axapta aif

我正在使用AIF web服务连接到Microsoft Dynamics AX 2009.在VS2010中为服务生成代理,但是当我想使用生成客户端类连接到服务时,似乎我没有在系统中进行身份验证。

我甚至尝试添加域用户/通行证并使用Windows身份验证,如下所示:

var binding = new BasicHttpBinding();
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
binding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None;
binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
var address = new EndpointAddress(new Uri("http://dynamicsserver/salesorderservice.svc"));
var client = new SalesOrderServiceClient(binding, address);
client.ClientCredentials.Windows.ClientCredential = new NetworkCredential("admin", "pass", "domain);

默认绑定是HttpBinding,我正在尝试使用在同一台计算机上使用NetworkCredential中指定的同一帐户运行的控制台应用程序连接到AIF。

当应用程序连接到Web服务时,我收到以下错误:

System.ServiceModel.FaultException: You cannot log on to Microsoft Dynamics AX.. Error details: Unable to log on to Microsoft Dynamics AX.. Check the Web server event viewer for more information, or contact your Administrator.

Server stack trace: 
   at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]: 
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)

2 个答案:

答案 0 :(得分:0)

  

您无法登录Microsoft Dynamics AX。检查网络   服务器事件查看器以获取更多信息,或联系您的   管理员。

也许您没有被创建为AX用户?

另请检查Administration \ Setup \ Security \ System服务帐户,尤其是“业务连接器代理”。

如果全部失败,请检查您的Web服务器的日志或联系您的系统管理员: - )

答案 1 :(得分:0)

尝试以下

        AX ax = new AX();//where AX=YourWebServiceClient

        ax.ChannelFactory.Credentials.UserName.UserName = @"domain\username";
        ax.ChannelFactory.Credentials.UserName.Password = @"password";

        CallContext context = new CallContext();
        context.Company = "YourCompany";

        Console.WriteLine(ax.YourServiceFunction(context));