Error: No había ningún punto final escuchando en…

programación


WCF y HTTPS, error: no había ningún punto final escuchando. Esto suele deberse a una dirección incorrecta o una acción SOAP

Estoy intentando configurar un servicio WCF para que funcione a través de HTTPS y tengo muchos problemas.

Estaba implementando https en mi servidor de desarrollo con un certificado autofirmado, todo funcionó bien. Cuando pasé a producción, todos los valores de las URL se leían con el nombre del servidor en lugar de la dirección de mi sitio web.

Agregué un encabezado de host a HTTPS en mi servidor web que debería permitirme evitar el uso de wsdl y xsd estáticos, pero no es así. Sin valores estáticos, todas las URL tienen por defecto el nombre del servidor.

Entonces, configuré el servicio para que tenga archivos wsdl y xsd estáticos que contengan https dentro de su dirección. Luego copié esos archivos al directorio de mi sitio web para que estén alojados. Esos archivos están alojados en mi sitio web y la dirección que se utiliza se resuelve correctamente.

En mi wsdl para mi dirección soad tengo un valor con https. El valor https está provocando un error. Cuando reemplazo https con http el servicio funciona pero cuando

Lo compruebo con Wire Shark y los datos no están cifrados. No es bueno.
¿Cómo puedo hacer que esto funcione?

Tengo un proyecto de prueba que puedo enviar para prueba.
Aquí está el error que recibo:

There was no endpoint listening at https://MYSERVICE/GpTest/Service1.svc that could accept the message.
This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
The remote server returned an error: (404) Not Found
Server stack trace:
   at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason)
   at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
   at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at TestWcfHttps1Caller.ServiceReference1.IService1.DoAddition(Int32 value1, Int32 value2)
   at TestWcfHttps1Caller.ServiceReference1.Service1Client.DoAddition(Int32 value1, Int32 value2) in C:\www\releases\Test\WCF\TestWcfHttps1Caller\Service References\ServiceReference1\Reference.cs:line 123
   at TestWcfHttps1Caller._Default.Page_Load(Object sender, EventArgs e) in C:\www\releases\Test\WCF\TestWcfHttps1Caller\Default.aspx.cs:line 15
   at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
   at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
   at System.Web.UI.Control.OnLoad(EventArgs e)
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Solución 1

Lo hice funcionar, fue necesaria una combinación de tres soluciones diferentes.

1. Habilite el encabezado del host HTTPS
2. Habilite archivos estáticos wsdl y xsd
3. Configurar web.config

Entonces, para habilitar HTTPS para WCF tuve que

1. Cree archivos estáticos wsdl y xsd

¿Vale, cómo?
1.1 siguiendo el enlace ?wsdl y guárdelo como tipo de archivo .wsdl. Modifique el archivo y cambie la dirección soad a https. Se vinculará a este archivo desde su servidor de desarrollo, ya que lo más probable es que su servidor en vivo tenga un vínculo al nombre del servidor y no a la URL que realmente desea usar.
1.2 en el archivo .wsdl cree un archivo .xsd para cada enlace xsd dentro del wsdl (es decir: xsd0.xsd, xsd1.xsd, xsd2.xsd)
1.3 actualice todas las referencias a los documentos xsd en el archivo wsdl y los archivos xsd para usar los nuevos archivos xsd que creó. Señale los valores alojados usando la URL que desea usar; todas las direcciones ahora deberían usar https
1.3 alojar todos esos archivos en la raíz de su aplicación web y probar que cada URL se resuelva correctamente
1.4 Nota: cada vez que realice cambios en el servicio necesitará reconstruir todos los archivos estáticos de esta manera

2. Habilite el encabezado del host HTTPS en el servidor IIS en vivo (no hay interfaz gráfica de usuario para esto, debe usar la línea de comando)

3. Modifique la configuración web del servicio para incluir el modo de seguridad de transporte y HTTPS en los siguientes atributos (busque “https” en web.config a continuación)

Aquí está mi archivo web.config

XML
<system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="TransportSecurity">
          <security mode="Transport">
            <transport clientCredentialType="None"/>
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <services>
      <service  behaviorConfiguration="TestWcfHttps1.Service1" name="TestWcfHttps1.Service1">
        <endpoint address="https://MYSERVER/GpTest/Service1.svc" 
                  binding="basicHttpBinding" 
                  bindingConfiguration="TransportSecurity"
                  contract="TestWcfHttps1.IService1">
          <identity>
            <dns value="" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="TestWcfHttps1.Service1">
          <serviceMetadata httpsGetEnabled="true" externalMetadataLocation="https://MYSERVER//GpTest/Service1.wsdl" />
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
</configuration>

コメント

タイトルとURLをコピーしました