Pregunta

Estoy ejecutando un servicio sencillo en mi servidor con WCF;el servicio está alojado en WebDev.WebServer.exe (local).

Cuando llamo al Servicio local me sale la siguiente excepción:

Excepción no controlada:System.ServiceModel.Security.SecurityNegotiationException:No se puede abrir el canal seguro porque falló la negociación de seguridad con el punto final remoto.Esto puede deberse a que EndpointIdentity está ausente o se ha especificado incorrectamente en EndpointAddress utilizado para crear el canal.Verifique que EndpointIdentity especificada o implícita en EndpointAddress identifique correctamente el punto final remoto.---> System.ServiceModel.FaultException:El mensaje con Acción 'http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Issue'No se puede procesar en el receptor, debido a un desajuste de contrato en el EndpointDispatcher.Esto puede deberse a bien un desajuste contractual (Acciones desajustadas entre el emisor y el receptor) o un desajuste vinculante/de seguridad entre el emisor y el receptor.Compruebe que el remitente y el destinatario tengan el mismo contrato y la misma vinculación (incluidos los requisitos de seguridad, p. ej.Mensaje, Transporte, Ninguno).

Aquí están mis dos archivos app.config del cliente y del servidor.Hice app.config desde el cliente con svcutil-Tool, por lo que debería ser correcto:

Cliente

<client>
    <endpoint address="http://localhost:1634/UsuarioContexto.svc" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IUsuarioContexto"

        contract="CarWin.ServiceContracts.Interfaces.IUsuarioContexto" name="LOCAL_WSHttpBinding_IUsuarioContexto">

        <identity><dns value="localhost" /></identity>

    </endpoint>

</client>

<binding name="WSHttpBinding_IUsuarioContexto" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">

    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />

    <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />

    <security mode="Message">

        <transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />

        <message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default" establishSecurityContext="true" />

    </security>

</binding>

Servidor

<services>
    <service behaviorConfiguration="UsuarioContextoBehavior" name="UserContext.Host.UsuarioContexto">

        <endpoint address="" binding="wsHttpBinding" bindingNamespace="http://CarWin" bindingConfiguration="wsHttpBinding_IUsuarioContexto"

                  contract="CarWin.ServiceContracts.Interfaces.IUsuarioContexto">

            <identity>

                <dns value="localhost" />

            </identity>

        </endpoint>

        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />

    </service>

</services>


<bindings>

    <wsHttpBinding>

        <binding name="wsHttpBinding_IUsuarioContexto" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">

            <readerQuotas maxArrayLength="2147483647" maxStringContentLength="2147483647" maxBytesPerRead="2147483647" />

            <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />

            <security mode="None">

                <transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />

                <message clientCredentialType="Windows" negotiateServiceCredential="true" establishSecurityContext="true" />

            </security>

        </binding>

    </wsHttpBinding>

</bindings>

<behaviors>

    <serviceBehaviors>

        <behavior name="UsuarioContextoBehavior">

            <serviceMetadata httpGetEnabled="true" />

            <serviceDebug includeExceptionDetailInFaults="true" />

        </behavior>

    </serviceBehaviors>

</behaviors>
¿Fue útil?

Solución

El problema estaba en el servidor, puse mode="Mensaje" y funciona bien.gracias.

<security mode="None">  

<transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />  

<message clientCredentialType="Windows" negotiateServiceCredential="true" establishSecurityContext="true" />  

</security> 

Otros consejos

WCF es muy poderoso, pero puede ser una pesadilla de configuración.Aquí hay algunas pistas potenciales:

  • Active los registros de seguimiento de WCF, vuelva a ejecutar su escenario y luego verifique los registros con SvcTraceViewer.exe
  • Descubra hasta dónde llegan los mensajes...
    • es decir.¿El cliente forma la solicitud y la envía al servidor quien la rechaza (es decir,en las capas inferiores de WCF antes de que se acceda a su propio código de servicio);
    • ¿O la solicitud se detiene en seco antes de eso?El cliente ni siquiera envía la solicitud.
  • http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Issue es un mensaje relacionado con el token WS-Trust, por lo que algo sucederá con la autenticación
    • el error implica que hay una discrepancia en la configuración, pero usar SvcUtil debería alinearlos como dijiste
  • El enlace del cliente tiene el servidor en "http://localhost:1634/UsuarioContexto.svc"
    • No veo ese puerto especificado en la configuración del servicio...¿El servicio está escuchando en ese puerto?
    • Si abre un navegador y apunta a esa URL, ¿obtiene una página de servicio predeterminada?
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top