我有一台安装了AX2012的远程计算机,在其中我已经在AX2012中构建了一个自定义服务,我可以在
Windows控制台应用程序(VS2010)中正确使用它.但是,当我尝试通过Windows控制台应用程序(VS2012)从我自己的计算机连接到服务时,它给出了错误“服务器已拒绝客户端凭据”.
我的代码如下:
ServiceReference1.TestService1Client t = new ServiceReference1.TestService1Client(); t.ClientCredentials.UserName.UserName = "vanya"; t.ClientCredentials.UserName.Password = "*******"; t.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation; ServiceReference1.CallContext c = new ServiceReference1.CallContext(); c.Company = "ussi"; ServiceReference1.EventList eventss = t.getEventItems(c,"BradPSUS","contoso.com");
app.config中的绑定如下:
<bindings> <netTcpBinding> <binding name="NetTcpBinding_TestService1" transferMode="Buffered" /> <binding name="NetTcpBinding_ItemService" /> </netTcpBinding> </bindings>
如果我在app.config中添加安全模式=“无”,我会收到以下错误“套接字连接已中止.这可能是由于处理消息时出错或远程主机超出接收超时或基础网络资源问题.本地套接字超时为’00:00:59.9609696’“
同样的事情在远程机器上完美运行但在我的机器上不起作用.我该怎么办?
解决方法
一周后我找到了解决方案.添加答案以帮助将来可能面临此问题的其他人:
>将服务的适配器从Net.Tcp更改为HTTP
>转到AX-> Inbound Port-> Configure,更改服务绑定的安全性详细信息.
>在IIS中托管服务,如果要从其他域使用服务,则必须在IIS上托管服务.此链接说明了流程http://technet.microsoft.com/en-us/library/gg731848.aspx
>仅在IIS上启用Windows身份验证.
>在Visual Studio上安装AX的同一台机器上创建一个控制台应用程序.添加对服务的引用.您的app.config应如下所示:
<?xml version="1.0" encoding="utf-8" ?> <configuration> <system.serviceModel> <bindings> <basicHttpBinding> <binding name="BasicHttpBinding_Service1" allowCookies="true" maxBufferPoolSize="20000000" maxBufferSize="20000000" maxReceivedMessageSize="20000000"> <readerQuotas maxDepth="32" maxStringContentLength="200000000" maxArrayLength="200000000" /> <security mode="TransportCredentialOnly"> <transport clientCredentialType="Windows" /> </security> </binding> </basicHttpBinding> </bindings> <client> <endpoint address="http://******/MicrosoftDynamicsAXaif60/Test3/xppservice.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_Service1" contract="ServiceReference1.Service1" name="BasicHttpBinding_Service1" > </endpoint> </client> </system.serviceModel> </configuration>
>获取此控制台应用程序的DLL并将其粘贴到您的其他计算机(不在同一域中的计算机)上
>创建一个控制台应用程序并添加对此dll的引用.使用此dll访问该服务.
>粘贴相同的app.config内容.
>在.cs文件中添加这三行
workListSvc.ClientCredentials.Windows.ClientCredential.Domain = "*****"; workListSvc.ClientCredentials.Windows.ClientCredential.UserName = "kevin"; workListSvc.ClientCredentials.Windows.ClientCredential.Password = "*****";
>现在应该工作.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。