2009-05-14 8 views
4

J'écris un service qui permet aux utilisateurs de s'enregistrer avec lui et de recevoir des notifications lorsqu'un événement se produit. J'essaye de faire ceci avec netTcpBinding, mais continue à venir avec des erreurs, même en cours d'exécution sur ma machine locale.Service duplex WCF utilisant net tcp: "Stream Security est requis ..."

Lorsque je tente d'envoyer une notification, je suis temporisation à, obtenir cette erreur:

Stream Security is required at http://www.w3.org/2005/08/addressing/anonymous , but no security context was negotiated. This is likely caused by the remote endpoint missing a StreamSecurityBindingElement from its binding.

Pour les tests, je suis d'hébergement du service dans une console, et il est l'ouverture pour moi et je peux voir la WSDL et lancez svcutil dessus. Quand je cours le client, et essaye d'envoyer une notification est quand l'erreur ci-dessus apparaît.

hôte 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> 

Voici le 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> 

J'ai omis beaucoup de code d'enregistrement depuis J'essaie seulement de faire fonctionner la notification maintenant.

Le plan est d'héberger cela dans un service Windows 2003 Server qui ne fait pas partie du domaine du client (leur configuration), et les ordinateurs clients seront sur le domaine du client.

Edit:

J'ai ajouté les liaisons au App.config de l'hôte:

<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> 

Cette erreur de toujours, avec le même message d'erreur est nécessaire sécurité à la vapeur. Essayer un petit sous-ensemble de cette application dans une nouvelle solution.

Répondre

9

Eh bien, votre problème semble être ceci:

  • sur le côté serveur, vous utilisez un défaut NetTcp lier sans paramètre - vous ne changez rien sur elle. par défaut NetTcp à la sécurité au niveau transport avec les informations d'identification de Windows

  • sur votre client cependant, vous désactiver explicitement toute sécurité sur le NetTcp liant

Donc, les deux ne correspondent pas et ne sont pas d'accord sur Que faire. Vous devez désactiver toutes les sécurités aux deux extrémités (serveur et client) ou utiliser uniquement les valeurs par défaut sécurisées (avec les informations d'identification Windows).

Marc

+0

Génial! Je pensais que la découverte VS l'avait fait correctement, mais même alors je devais éditer la config. Merci! – rozon

3

Je pense qu'il se c'est l'un de ces messages d'erreur horribles que vous conduit dans de nombreuses directions différentes. Les réponses ci-dessus sont correctes pour ce cas. Mon cas était différent - mes paramètres de sécurité étaient identiques sur le client et servir.

Dans mon cas, ce lien a souligné mon défaut particulier: http://www.netframeworkdevs.com/windows-communication-foundation-wcf/error-invoking-service-with-a-net-tcp-binding-123918.shtml.

Mon app.config côté service pour l'extrémité avait bindingName comme attribut pour nommer la configuration de liaison ... au lieu de bindingConfiguration. Je ne pense pas qu'il existe même un attribut nommé bindingName sur un endpoint. Donc, mon erreur est que cette erreur signifie "il y a une erreur de configuration WCF" peut-être réduite à la configuration côté service. Pouah.

+0

+1 Il y a en effet un attribut 'bindingName', mais merci - le' bindingConfiguration' manquant était le problème pour moi. – ildjarn