3

这是我的服务器端app.config

<services>
  <service name="PokerService.PlayerService" behaviorConfiguration="ServiceBehaviorPlayer">
    <host>
      <baseAddresses>
        <add baseAddress="net.tcp://localhost:5054" />
      </baseAddresses>
    </host>
    <!-- Service Endpoints -->
    <endpoint  address="player" binding="netTcpBinding" bindingConfiguration="PlayerBinding" contract="PokerService.IPlayerService" />
    <endpoint address="player/mex" binding="mexTcpBinding" name="ServiceBehaviorPlayer" contract="IMetadataExchange"  />
  </service>
</services>

我正在客户端代码中生成动态端点:

ServiceHost host = new ServiceHost(typeof(PokerService.PlayerService));

NetTcpBinding binding = new NetTcpBinding(SecurityMode.Message);
binding.Name = "NetTcpBinding_IPlayerService";
binding.Security.Message.ClientCredentialType = MessageCredentialType.IssuedToken;

ServiceEndpoint ep = host.AddServiceEndpoint(
            typeof(PokerService.IPlayerService),
            binding,
            "net.tcp://localhost:5054");
        EndpointAddress myEndpointAdd = new EndpointAddress(new Uri("net.tcp://localhost:5054/player1"),
             EndpointIdentity.CreateDnsIdentity("pident.cloudapp.net"));
        ep.Address = myEndpointAdd;

对于服务测试代码:

var PlayerChannelFactory = new DuplexChannelFactory<ClientApplication.PlayerService.IPlayerService>(new PlayerHandler(handler, this), binding, ep.Address);

PlayerChannelFactory.Credentials.SupportInteractive = false;
        PlayerChannelFactory.Credentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None;
PlayerServiceProxy = PlayerChannelFactory.CreateChannelWithIssuedToken(User.Instance.userToken);

现在我收到此错误

错误

任何想法?

4

3 回答 3

2

客户端配置文件如下所示:

<client>
      <endpoint address="net.tcp://localhost:5054/player" binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IPlayerService" contract="PlayerService.IPlayerService" name="NetTcpBinding_IPlayerService">
      <identity>
          <dns value="pident.cloudapp.net"/>
        </identity>
      </endpoint>
         </client>
于 2013-04-16T04:09:07.750 回答
0

我还认为您的服务和客户端之间存在端点不匹配。尝试:

new EndpointAddress(new Uri("net.tcp://localhost:5054/player")

客户端配置文件长什么样?

于 2013-04-15T13:03:07.447 回答
0

由于您可以在同一地址上托管多个服务(使用端口共享,...) - 您的服务端点地址定义了“您正在寻找哪些服务”。

因此,正如@Backlash 还提到的,您的客户端的 uri 应该指向正确的服务器地址。

于 2013-04-15T13:00:42.787 回答