2011-07-15 78 views
1

我正在使用AIF webservices連接到Microsoft Dynamics AX 2009.爲VS2010中的服務生成代理,但是當我想使用生成客戶端類連接到服務時,似乎我沒有在系統中進行身份驗證。使用AIF webservices連接到Microsoft Dynamics AX 2009

我甚至嘗試添加域用戶名/密碼,並使用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,我試圖使用運行一個控制檯應用程序連接到AIF使用同一臺機器上的NetworkCredential中指定的相同帳戶。

我收到以下錯誤,當應用程序連接到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) 

回答

0

您無法登錄到Microsoft Dynamics AX。查看Web 服務器事件查看器以獲取更多信息,或者聯繫您的 管理員。

也許您還沒有被創建爲AX用戶?

另請檢查Administration \ Setup \ Security \ System服務帳戶,特別是「業務連接器代理」。

如果所有失敗,請檢查你的web服務器的日誌或與系統管理員聯繫:-)

+0

我可以使用業務連接器連接,但做起事情來就失敗了同一臺機器,當我使用web服務。 「業務連接器代理」設置是正確的,因爲業務連接器正常工作。 –

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)); 
相關問題