Gro*_*mer 4 c# wcf web-services duplex
我正在编写一项服务,允许用户注册并在事件发生时接收通知.我正在尝试使用netTcpBinding执行此操作,但即使在本地计算机上运行时也会遇到错误.
当我尝试发送通知时,我超时,收到此错误:
http://www.w3.org/2005/08/addressing/anonymous需要Stream Security ,但没有协商安全上下文.这可能是由远程端点从其绑定中丢失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>
Run Code Online (Sandbox Code Playgroud)
这是客户端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>
Run Code Online (Sandbox Code Playgroud)
我省略了很多注册码,因为我现在只是想让通知正常工作.
计划是在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>
Run Code Online (Sandbox Code Playgroud)
这仍然是错误,具有相同的Steam Security是必需的错误消息.在新解决方案中尝试此应用的一小部分.
好吧,你的问题似乎是这样的:
在服务器端,您使用没有参数的默认netTCP绑定 - 您不会更改任何内容.netTCP默认使用Windows凭据进行传输级安全性
但是,在您的客户端上,您明确关闭了netTCP绑定的任何安全性
所以两者不匹配,不同意做什么.
您需要关闭BOTH两端的所有安全性 - 服务器和客户端 - 或者您只需使用安全默认值(使用Windows凭据).
渣