C# 在windows控制台应用程序中使用ax2012服务
我有一台安装了AX2012的远程计算机,其中我在AX2012中构建了一个自定义服务,我能够在windows控制台应用程序(VS2010)中正确使用它。但是,当我试图通过windows控制台应用程序(VS2012)从自己的计算机连接到该服务时,它会给我一个错误“服务器拒绝了客户端凭据” 我的代码如下:C# 在windows控制台应用程序中使用ax2012服务,c#,visual-studio-2010,visual-studio-2012,nettcpbinding,dynamics-ax-2012,C#,Visual Studio 2010,Visual Studio 2012,Nettcpbinding,Dynamics Ax 2012,我有一台安装了AX2012的远程计算机,其中我在AX2012中构建了一个自定义服务,我能够在windows控制台应用程序(VS2010)中正确使用它。但是,当我试图通过windows控制台应用程序(VS2012)从自己的计算机连接到该服务时,它会给我一个错误“服务器拒绝了客户端凭据” 我的代码如下: ServiceReference1.TestService1Client t = new ServiceReference1.TestService1Client(); t.Cli
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");
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_TestService1" transferMode="Buffered" />
<binding name="NetTcpBinding_ItemService" />
</netTcpBinding>
</bindings>
my app.config中的绑定如下所示:
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");
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_TestService1" transferMode="Buffered" />
<binding name="NetTcpBinding_ItemService" />
</netTcpBinding>
</bindings>
如果我在app.config中添加security mode=“none”,则会出现以下错误“套接字连接被中止。这可能是由于处理消息时出错、远程主机超过接收超时或基础网络资源问题造成的。本地套接字超时为“00:00:59.9609696”
同样的东西在远程机器上工作得很好,但在我的机器上不工作。我该如何进行 一周后,我找到了解决办法。添加答案以帮助将来可能面临此问题的其他人:
<?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>
远程计算机是否在内部网络上运行?此网络与本地计算机的网络相同吗?我没有使用AX 2012的经验,但如果您将安全模式设置为“无”,则会收到错误消息,并且它可以远程工作,这可能是不匹配的子网。远程计算机位于不同的域上。