我正在编写一项服务,允许用户注册并在事件发生时接收通知。我正在尝试使用 netTcpBinding 执行此操作,但即使在我的本地计算机上运行时也会不断出现错误。
当我尝试发送通知时,我超时,收到此错误:
http://www.w3.org/2005/08/addressing/anonymous需要流安全,但没有协商安全上下文。这可能是由于远程端点在其绑定中缺少 StreamSecurityBindingElement 造成的。
为了进行测试,我将服务托管在控制台中,它正在为我打开,我可以看到 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>
这是客户端 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>
我省略了很多注册码,因为我现在只是想让通知正常工作。
计划是在不属于客户域(他们的设置)的 2003 Server 中的 Windows 服务中托管它,并且客户端计算机将在客户的域中。
编辑:
我已将绑定添加到主机的 App.config:
<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 Security is required 错误消息。在新解决方案中尝试此应用程序的一小部分。