Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/visual-studio-2010/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/467.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在windows控制台应用程序中使用ax2012服务_C#_Visual Studio 2010_Visual Studio 2012_Nettcpbinding_Dynamics Ax 2012 - Fatal编程技术网

C# 在windows控制台应用程序中使用ax2012服务

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

我有一台安装了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");
 <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”


同样的东西在远程机器上工作得很好,但在我的机器上不工作。我该如何进行

一周后,我找到了解决办法。添加答案以帮助将来可能面临此问题的其他人:

  • 将服务的适配器从Net.Tcp更改为HTTP

  • 通过转到AX->Inbound Port->Configure更改服务绑定的安全详细信息。

  • 在IIS中托管服务,如果要从其他域使用服务,则必须在IIS上托管服务。这个链接解释了这个过程

  • 仅在IIS上启用windows身份验证。

  • 在安装AX的同一台计算机上的visual studio中创建控制台应用程序。添加对服务的引用。您的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>
    
  • 现在应该可以工作了


  • 远程计算机是否在内部网络上运行?此网络与本地计算机的网络相同吗?我没有使用AX 2012的经验,但如果您将安全模式设置为“无”,则会收到错误消息,并且它可以远程工作,这可能是不匹配的子网。远程计算机位于不同的域上。