2011-07-08 13 views
8

Jestem całkowicie nowy i próbuję hostować najprostszą usługę WCF z wiązaniem net.tcp. Mam Windows 7 Professional i IIS7 i włączyłem aktywację NON http.Hosting usługi WCF za pomocą Net.TCP

  • Rozpoczęcie nowego projektu usługi WCF w projekcie vs2010 i skompilowanie go. NOHTING ELSE!
  • usunąć wszystkie moje IIS stron WWW i dodać nowy nazywa WCFHost
  • ja otworzyć WcfTestClient.exe i dodaje http://localhost/Service1.svc aplikacja znajdzie to

web.config wygląda następująco (nietknięte)

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

Jak dotąd, tak dobrze. Ale co z powiązaniem net.tcp. I dodać atrybut „enabledProtocols” więc moja applicationHost.config wygląda następująco

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

Potem przejdź do witryny IIS WCFHost i dodać wiązania Net.TCP 808: * I wtedy zmodyfikować moje web.config dla Usługa WCF wyglądać tak. (Tylko zmienił wiążące dla punktów końcowych)

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

Kiedy teraz spróbuj dodać Net.TCP usług: // localhost: 808/Service1.svc w moim WcfTestClient.exe pojawia się błąd

Błąd: Nie można uzyskać metadanych z pliku net.tcp: //localhost/Service1.svc Kod błędu TCP 10061: Nie można nawiązać połączenia, ponieważ komputer docelowy aktywnie go odrzucił ... 127.0.0.1:808

Moja zapora ogniowa jest wyłączony. Widziałem jedną rzecz, chociaż .. podczas korzystania z netstat -a port 808 nie jest tam wymieniony .. czy powinien?

Czy ktoś może mi pomóc w tworzeniu mojej pierwszej usługi WCF z wiązaniem nettcp?

Odpowiedz

7

Powiązania net.tcp są włączone w IIS dla żądań 808? Sprawdź to na menedżerze/powiązaniach IIS.

See it

+0

Dzięki za milion! Walczyłem z tym przez cały dzień :) – Martin

13

Jak mówi Tocco sprawdzić, czy usługa jest uruchomiona. Można to zrobić poprzez sprawdzenie:

netstat /an | find /i "808 "

A powinien wykazać:

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

jeśli usługa działa poprawnie.

aby ją rozpocząć, jeśli nie jest już działa, można wydać:

sc start NetTcpActivator

z wiersza poleceń do ttry aby go uruchomić.

Jeszcze wcześniej upewnij się, że the non-HTTP activation windows components are installed.

Sprawdź również, czy usługi rzeczywiście działają. I had a problem where they would not necessarily start after a reboot.

Powiązane problemy