2009-08-19 14 views
7

Estoy teniendo un momento difícil con NetTcpBinding.WCF Service Library con NetTcpBinding

Cuando ejecuto mi WCFservice, me sale esto:

System.InvalidOperationException: Could not find a base address that matches scheme net.tcp for the endpoint with binding NetTcpBinding. Registered base address schemes are [http]. 
    at System.ServiceModel.ServiceHostBase.MakeAbsoluteUri(Uri relativeOrAbsoluteUri, Binding binding, UriSchemeKeyedCollection baseAddresses) 
    at System.ServiceModel.Description.ConfigLoader.LoadServiceDescription(ServiceHostBase host, ServiceDescription description, ServiceElement serviceElement, Action`1 addBaseAddress) 
    at System.ServiceModel.ServiceHostBase.LoadConfigurationSectionInternal(ConfigLoader configLoader, ServiceDescription description, ServiceElement serviceSection) 
    at System.ServiceModel.ServiceHostBase.LoadConfigurationSectionInternal(ConfigLoader configLoader, ServiceDescription description, String configurationName) 
    at System.ServiceModel.ServiceHostBase.ApplyConfiguration() 
    at System.ServiceModel.ServiceHostBase.InitializeDescription(UriSchemeKeyedCollection baseAddresses) 
    at System.ServiceModel.ServiceHost.InitializeDescription(Type serviceType, UriSchemeKeyedCollection baseAddresses) 
    at System.ServiceModel.ServiceHost..ctor(Type serviceType, Uri[] baseAddresses) 
    at Microsoft.Tools.SvcHost.ServiceHostHelper.CreateServiceHost(Type type, ServiceKind kind) 
    at Microsoft.Tools.SvcHost.ServiceHostHelper.OpenService(ServiceInfo info) 

me estoy haciendo esto cuando funciono con la aplicación de forma predeterminada utilizando WCFSvcHost. No hay código adicional. Simplemente el código predeterminado de cualquier servicio wcf nuevo. Todo lo que quería hacer era cambiar el enlace a tcp.

¿Cómo resuelvo este problema?

Editar: Aquí está de App.config

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <system.web> 
    <compilation debug="true" /> 
    </system.web> 
    <system.serviceModel> 
    <bindings> 
     <netTcpBinding> 
     <binding name="tcpBinding" transferMode="Streamed" portSharingEnabled="false"> 
      <reliableSession enabled="true" /> 
      <security mode="None"> 
      <transport clientCredentialType="None" protectionLevel="None" /> 
      <message clientCredentialType="None" /> 
      </security> 
     </binding> 
     </netTcpBinding> 
    </bindings> 
    <services> 
     <service behaviorConfiguration="WcfServiceLibrary1.Service1Behavior" 
     name="WcfServiceLibrary1.Service1"> 
     <endpoint address="" binding="wsHttpBinding" contract="WcfServiceLibrary1.IService1"> 
      <identity> 
      <dns value="localhost" /> 
      </identity> 
     </endpoint> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
     <endpoint address="Service" binding="netTcpBinding" bindingConfiguration="tcpBinding" 
      name="testTcp" contract="WcfServiceLibrary1.IService1" /> 
     <host> 
      <baseAddresses> 
      <add baseAddress="http://localhost:8731/Design_Time_Addresses/WcfServiceLibrary1/Service1/" /> 
      </baseAddresses> 
     </host> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="WcfServiceLibrary1.Service1Behavior"> 
      <serviceMetadata httpGetEnabled="True"/> 
      <serviceDebug includeExceptionDetailInFaults="False" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    </system.serviceModel> 
</configuration> 
+0

Podría publicar la configuración de WCF de aplicación/web.config? – jrista

+0

No se está haciendo visible aunque lo publique – Josh

+0

después de agregarlo, presione el botón de código (para sangrar cada línea 4 espacios y no interpretar el xml) – Brian

Respuesta

7

mi WCF En esta sección

<host>   
    <baseAddresses>    
    <add baseAddress="http://localhost:8731/.../" /> 
    </baseAddresses>   
</host> 

añadir un net.tcp: // dirección base.

<host> 
    <baseAddresses> 
    <add baseAddress="http://localhost:8732/" /> 
    <add baseAddress="net.tcp://localhost"/> 
    </baseAddresses> 
</host> 
+0

añadiendo que no funciona. Dice que el puerto está en uso tipo de error. ¿Podría completar esa línea por favor? Gracias – Josh

+0

System.ServiceModel.AddressAlreadyInUseException: TransportManager no pudo escuchar en el URI proporcionado utilizando el servicio NetTcpPortSharing: el servicio no pudo escuchar. – Josh

+0

Asegúrese de utilizar un puerto diferente (por ejemplo, si http está en 8731, luego use, por ejemplo, 8732: net.tcp: // localhost: 8732/Yadda/Blah /) – Brian

18

estoy seguro de que ahora se haya solucionado el problema, pero realmente no es nada que ver con baseAddresses que es lo que todas las tablas Bullentin llevará a. Encontré la respuesta al http://social.msdn.microsoft.com/forums/en-US/wcf/thread/c9f8d99d-89ee-4573-8528-a21b047bad11. Suponiendo que está utilizando IIS 7.x: haga clic con el botón derecho en el directorio/aplicación virtual en IIS, seleccione Administrar aplicación -> Configuración avanzada. En la sección 'Protocolos habilitados', agregue net.tcp, por ejemplo, http, net.tcp. Esto es necesario incluso si agregó este protocolo ya en el nivel del sitio.

+0

Veo que también tiene el modo de seguridad establecido en Ninguno en sus enlaces , que es lo que comencé a usar al principio, sin embargo, para lo que estoy haciendo necesito conocer a la persona autenticada. Normalmente obtengo esto de OperationContext.Current.ServiceSecurityContext.PrimaryIdentity.Name (http://www.leastprivilege.com/HostingWCFServicesInASPNETTheSurvivalGuide.aspx). Así que, en cambio, modifiqué los enlaces en * both * el cliente y el servidor a Windows según http://msdn.microsoft.com/en-us/library/ms733089.aspx (Seguridad de transporte con autenticación de Windows). – Helder

+0

cómo hacer esto en IIS6? ¿Algunas ideas? – NLV

+0

Gracias ... He estado mirando este archivo de configuración durante aproximadamente 2 horas y no pude entender qué estaba pasando ... – SoftwareSavant

1
  1. comprobar el puerto servicio de uso compartido net.tcp se inicia en la máquina
  2. Verificar la configuración de atributos netTcpBinding portSharingEnabled es cierto. (En WCF4 no necesita proporcionar un nombre en el elemento de enlace si desea que esta especificación de enlace sea la predeterminada para net.tcp)
2

Configure el enlace net.tcp en su sitio IIS y establezca el protocolo habilitado como "http, net.tcp utilizando configuración avanzada". Debería funcionar

3

Puede compartir puertos, no es demasiado difícil.

Al seleccionar protocolos habilitados en IIS (haga clic con el botón derecho en el sitio -> Administrar sitio web -> Configuración avanzada), asegúrese de que NO UTILIZA ESPACIOS. Si tiene "http, net.tcp" en lugar de "http, net.tcp", no funcionará, y en cambio le dará este error exacto.

Más información aquí: http://www.weeksofprogramming.com/post/Could-not-find-a-base-address-Check-for-spaces-in-IIS7.aspx

Cuestiones relacionadas