简体   繁体   中英

Using AIF webservices to connect to Microsoft Dynamics AX 2009

I'm using AIF webservices to connect to Microsoft Dynamics AX 2009. Proxies are generated for the service in VS2010, but when I want to connect to the service using generate client class, it seems I am not authenticated in the system.

I even tried adding a domain user/pass and use windows authentication, like this:

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);

Default binding is HttpBinding, and I'm trying to connect to the AIF using a console application that is running using the same account specified in NetworkCredential on the same machine.

I get the following error when application connects to the webservice:

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)

Try the following

        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));

You are unable to log on to Microsoft Dynamics AX. Check the Web server event viewer for more information, or contact your Administrator.

Maybe you do not have been created as an AX user?

Also check Administration\Setup\Security\System service accounts especially the "Business connector proxy".

If all fails, check the logs of your web server or contact your system administrator:-)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM