代码之家  ›  专栏  ›  技术社区  ›  Gromer

使用网络tcp的WCF双工服务:“需要流安全性…”

  •  4
  • Gromer  · 技术社区  · 15 年前

    我正在编写一个服务,允许用户在事件发生时向它注册并接收通知。我试图用netTcpBinding来实现这一点,但仍然会出现错误,即使是在本地机器上运行时。

    当我尝试发送通知时,我超时,出现以下错误:

    在以下位置需要流安全性: http://www.w3.org/2005/08/addressing/anonymous

    为了进行测试,我在控制台中托管服务,它正在为我打开,我可以看到WSDL并在其上运行svcutil。但是,当我运行客户端并尝试发送通知时,上面的错误就会出现。

    主机App.config:

    <system.serviceModel>
    <services>
      <service name="CompanyName.WebServices.InterventionService.RegistrationService"
               behaviorConfiguration="RegistrationServiceBehavior">
        <endpoint address="http://localhost:8000/CompanyName/Registration"
                  binding="wsDualHttpBinding"
                  contract="CompanyName.WebServices.InterventionService.Interfaces.IRegistrationService"/>
        <endpoint address="net.tcp://localhost:8001/CompanyName/Registration"
                  binding="netTcpBinding"
                  contract="CompanyName.WebServices.InterventionService.Interfaces.IRegistrationService"/>
      </service>
      <service name="CompanyName.WebServices.InterventionService.NotificationService"
               behaviorConfiguration="NotificationServiceBehavior">
        <endpoint address="http://localhost:8010/CompanyName/Notification"
                  binding="wsDualHttpBinding"
                  contract="CompanyName.WebServices.InterventionService.Interfaces.INotificationService"/>
        <endpoint address="net.tcp://localhost:8011/CompanyName/Notification"
                  binding="netTcpBinding"
                  contract="CompanyName.WebServices.InterventionService.Interfaces.INotificationService"/>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="RegistrationServiceBehavior">
          <serviceMetadata httpGetEnabled="true"
                           httpGetUrl="http://localhost:8000/CompanyName/Registration"/>
        </behavior>
        <behavior name="NotificationServiceBehavior">
          <serviceMetadata httpGetEnabled="true"
                           httpGetUrl="http://localhost:8010/CompanyName/Notification"/>
        </behavior>
        <behavior name="netTcpRegistrationServiceBehavior">
          <serviceMetadata httpGetEnabled="true"
                           httpGetUrl="net.tcp://localhost:8001/CompanyName/Registration"/>
        </behavior>
        <behavior name="netTcpNotificationServiceBehavior">
          <serviceMetadata httpGetEnabled="true"
                           httpGetUrl="net.tcp://localhost:8011/CompanyName/Notification"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    

    以下是client App.config:

    <system.serviceModel>
    <bindings>
      <netTcpBinding>
        <binding name="NetTcpBinding_IRegistrationService">
          <security mode="None">
            <message clientCredentialType="None"/>
            <transport clientCredentialType="None"/>
          </security>
        </binding>
        <binding name="NetTcpBinding_INotificationService">
          <security mode="None">
            <message clientCredentialType="None"/>
            <transport clientCredentialType="None"/>
          </security>
        </binding>
      </netTcpBinding>
      <wsDualHttpBinding>
        <binding name="WSDualHttpBinding_IRegistrationService">
          <reliableSession ordered="true"/>
          <security mode="None">
            <message clientCredentialType="None" negotiateServiceCredential="false"/>
          </security>
        </binding>
        <binding name="WSDualHttpBinding_INotificationService">
          <reliableSession ordered="true"/>
          <security mode="None">
            <message clientCredentialType="None" negotiateServiceCredential="false"/>
          </security>
        </binding>
      </wsDualHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost:8000/GPS/Registration"
                binding="wsDualHttpBinding"
                bindingConfiguration="WSDualHttpBinding_IRegistrationService"
                contract="IRegistrationService"
                name="WSDualHttpBinding_IRegistrationService">
      </endpoint>
      <endpoint address="net.tcp://localhost:8001/GPS/Registration"
                binding="netTcpBinding"
                bindingConfiguration="NetTcpBinding_IRegistrationService"
                contract="IRegistrationService"
                name="NetTcpBinding_IRegistrationService">
      </endpoint>
      <endpoint address="http://localhost:8010/GPS/Notification"
                binding="wsDualHttpBinding"
                bindingConfiguration="WSDualHttpBinding_INotificationService"
                contract="INotificationService"
                name="WSDualHttpBinding_INotificationService">
      </endpoint>
      <endpoint address="net.tcp://localhost:8011/GPS/Notification"
                binding="netTcpBinding"
                bindingConfiguration="NetTcpBinding_INotificationService"
                contract="INotificationService"
                name="NetTcpBinding_INotificationService">
      </endpoint>
    </client>
    

    计划将其托管在不属于客户域(其设置)的windows service in 2003服务器中,客户端计算机将位于客户域中。

    编辑:

    <bindings>
      <netTcpBinding>
        <binding name="NetTcpBinding_IRegistrationService">
          <security mode="None">
            <message clientCredentialType="None"/>
            <transport clientCredentialType="None"/>
          </security>
        </binding>
        <binding name="NetTcpBinding_INotificationService">
          <security mode="None">
            <message clientCredentialType="None"/>
            <transport clientCredentialType="None"/>
          </security>
        </binding>
      </netTcpBinding>
      <wsDualHttpBinding>
        <binding name="WSDualHttpBinding_IRegistrationService">
          <reliableSession ordered="true"/>
          <security mode="None">
            <message clientCredentialType="None" negotiateServiceCredential="false"/>
          </security>
        </binding>
        <binding name="WSDualHttpBinding_INotificationService">
          <reliableSession ordered="true"/>
          <security mode="None">
            <message clientCredentialType="None" negotiateServiceCredential="false"/>
          </security>
        </binding>
      </wsDualHttpBinding>
    </bindings>
    

    这仍然是错误,具有相同的Steam安全要求的错误消息。在新解决方案中尝试此应用的一小部分。

    2 回复  |  直到 15 年前
        1
  •  10
  •   marc_s    15 年前

    你的问题似乎是:

    • 但是,在客户端上,您可以显式地关闭netTCP绑定上的任何安全性

    所以这两个人不匹配,也不同意怎么做。

    马克

        2
  •  3
  •   Howard Hoffman    12 年前

    在我的例子中,这个链接指出了我的特殊缺陷: http://www.netframeworkdevs.com/windows-communication-foundation-wcf/error-invoking-service-with-a-net-tcp-binding-123918.shtml .

    终结点的我的服务端app.config已被删除 bindingName bindingConfiguration . 我甚至不认为有一个名为 绑定名 endpoint .

    所以我想说的是,这个错误意味着“存在WCF配置错误”,可能仅限于服务端配置。啊。