2011-07-08 5 views
8

Je suis totalement nouveau à cela et essayant d'héberger le service WCF le plus simple avec une liaison net.tcp J'ai Windows 7 Professionnel et IIS7 et j'ai activé l'activation NON-http.Héberger un service WCF avec Net.TCP

  • Je démarre un nouveau projet d'application de service WCF dans vs2010 et le compile. NOHTING ELSE!
  • -je supprimer tout mon IIS sites Web et ajouter un nouveau appelé WCFHost
  • J'ouvre WcfTestClient.exe et ajoute http://localhost/Service1.svc l'application trouve

web.config ressemble à ceci (intacte)

<system.serviceModel> 
    <services> 
     <service name="WcfService2.Service1" behaviorConfiguration="WcfService2.Service1Behavior"> 
     <endpoint address="" binding="wsHttpBinding" contract="WcfService2.IService1"> 
      <!-- 
       Upon deployment, the following identity element should be removed or replaced to reflect the 
       identity under which the deployed service runs. If removed, WCF will infer an appropriate identity 
       automatically. 
      --> 
      <identity> 
      <dns value="localhost"/> 
      </identity> 
     </endpoint> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="WcfService2.Service1Behavior"> 
      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --> 
      <serviceMetadata httpGetEnabled="true"/> 
      <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information --> 
      <serviceDebug includeExceptionDetailInFaults="false"/> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    </system.serviceModel> 

Jusqu'ici, tout va bien. Mais qu'en est-il de cette liaison net.tcp. J'ajoute le « enabledProtocols » attribut donc mon applicationHost.config ressemble à ceci

 <site name="WCFHOST" id="3"> 
      <application path="/" applicationPool="WCFHOST" enabledProtocols="http,net.tcp,net.pipe,net.msmq"> 
       <virtualDirectory path="/" physicalPath="C:\Prosjekter\temp\TestService\TestService" /> 
      </application> 
      <bindings> 
       <binding protocol="net.tcp" bindingInformation="808:*" /> 
       <binding protocol="http" bindingInformation="*:80:" /> 
      </bindings> 
     </site> 

Alors je vais sur le site Web IIS WCFHost et ajouter net.tcp liaison 808: * Et puis-je modifier mon web.config pour la Service WCF pour ressembler à ceci. (Juste changé la liaison sur les points d'extrémité)

<system.serviceModel> 
    <services> 
     <service name="WcfService2.Service1" behaviorConfiguration="WcfService2.Service1Behavior"> 
     <!-- Service Endpoints --> 
     <endpoint address="" binding="netTcpBinding" contract="WcfService2.IService1"> 
      <!-- 
       Upon deployment, the following identity element should be removed or replaced to reflect the 
       identity under which the deployed service runs. If removed, WCF will infer an appropriate identity 
       automatically. 
      --> 
      <identity> 
      <dns value="localhost"/> 
      </identity> 
     </endpoint> 
     <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"/> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="WcfService2.Service1Behavior"> 
      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --> 
      <serviceMetadata httpGetEnabled="true"/> 
      <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information --> 
      <serviceDebug includeExceptionDetailInFaults="false"/> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
</system.serviceModel> 

Lorsque je tente maintenant d'ajouter le net.tcp service: // localhost: 808/Service1.svc dans mon WcfTestClient.exe je reçois l'erreur

Erreur: impossible d'obtenir des métadonnées à partir de net.tcp: //localhost/Service1.svc TCP-errorcode 10061: Aucune connexion n'a pu être établie car la machine cible l'a refusée activement .... 127.0.0.1:808

Mon pare-feu est éteint. J'ai vu une chose, cependant .. lors de l'utilisation netstat -a le port 808 n'est pas répertorié là .. devrait-il?

Quelqu'un peut-il m'aider à créer mon premier service WCF avec la reliure nettcp?

Répondre

7

Les liaisons net.tcp sont activées sur IIS pour les demandes sur 808? Vérifiez-le sur le gestionnaire IIS/les liaisons.

See it

+0

Merci un million! J'ai lutté avec ça toute la journée :) – Martin

13

Comme le dit Tocco, vérifiez que le service est en cours d'exécution. Vous pouvez le faire en vérifiant:

netstat /an | find /i "808 "

Et il devrait montrer:

TCP 0.0.0.0:808 0.0.0.0:0 LISTENING
TCP [::]:808 [::]:0 LISTENING

si le service fonctionne correctement.

Pour l'obtenir pour commencer si ça fonctionne pas déjà, vous pouvez émettre:

sc start NetTcpActivator

de la ligne de commande pour ttry pour le démarrer.

Même avant cela, assurez-vous que the non-HTTP activation windows components are installed.

Vérifiez également que les services sont en cours d'exécution. I had a problem where they would not necessarily start after a reboot.

Questions connexes