2010-12-07 21 views
7

Estoy tratando de alojar el mismo servicio dentro del mismo sitio web utilizando dos puntos finales, uno HTTP y el otro HTTPS."Ya existe un registro para URI" al alojar el mismo servicio para HTTPS y HTTP

El problema es que felizmente puedo llamar a un servicio (lo que yo llamo primeros trabajos) pero luego llamar al otro falla hasta que vuelva a intentarlo. SO puedo felizmente llamar a ambos, pero uno a la vez hasta que un proceso se recicle.

He agotado (o creo que tengo) todos los Q relevantes y documentos que pude encontrar y ninguno de ellos parece ayudarme. El nivel de documentación de MSDN con respecto a estos casos (que debería ser muy común) es espantoso y nada funciona como parece.

He utilizado Host/BaseAddresses/BaseAddress sin suerte y cada vez que lo uso, aparece otro error (no se puede encontrar un esquema HTTPS).

Tengo una carpeta llamada Seguridad que está habilitada para HTTPS dentro de IIS.

He desactivado mex por lo que no se permitieron metadatos que obtuve pasaron los errores anteriores.

¿Alguien tiene una pista? ... Soy cluless

<service name="Namespace.MyService" behaviorConfiguration="MyBehaviour"> 
    <host> 
     <baseAddresses> 
     </baseAddresses> 
    </host> 
    <endpoint address="http://localhost/Services/MyService.svc/MyService" 
       name="MyService" binding="wsHttpBinding" 
       bindingConfiguration="myWsHttpBinding" contract="Namespace.IMyService" /> 

    <endpoint address="https://localhost/Services/Secure/MySslService.svc/MySslService" 
       name="MySslService" binding="basicHttpBinding" 
       bindingConfiguration="MySslServiceBinding" contract="Namespace.IMyService" /> 
    </service> 

.....

<behavior name="MyBehaviour"> 
     <custom1/> 
     <custom2/> 
     <serviceMetadata httpGetEnabled="false" /> 
     <serviceDebug includeExceptionDetailInFaults="false"/> 
     <serviceAuthorization principalPermissionMode="UseAspNetRoles" roleProviderName="CustomProvider"/> 
     <serviceCredentials> 
     <serviceCertificate findValue="Some" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName" /> 

     <userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="SomeClass, SomeDll"/> 
     </serviceCredentials> 
    </behavior> 

error original es:

A registration already exists for URI 'http://localhost/Services/....'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: A registration already exists for URI 'http://localhost/Services/....'.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[InvalidOperationException: A registration already exists for URI
System.ServiceModel.Channels.UriPrefixTable 1.RegisterUri(Uri uri, HostNameComparisonMode hostNameComparisonMode, TItem item) +320 System.ServiceModel.Channels.HttpTransportManager.Register(TransportChannelListener channelListener) +380
System.ServiceModel.Channels.TransportManager.Open(TransportChannelListener channelListener) +816
System.ServiceModel.Channels.TransportManagerContainer.Open(SelectTransportManagersCallback selectTransportManagerCallback) +121
System.ServiceModel.Channels.HttpChannelListener.OnOpen(TimeSpan timeout) +125
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +789
System.ServiceModel.Channels.DatagramChannelDemuxer
2.OnOuterListenerOpen(ChannelDemuxerFilter filter, IChannelListener listener, TimeSpan timeout) +606
System.ServiceModel.Channels.SingletonChannelListener`3.OnOpen(TimeSpan timeout) +91
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +789
System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout) +375

Aquí es el error WCF registro de seguimiento:

The ChannelDispatcher at 'http://localhost/Services/...' with contract(s) '"IMyService"' is unable to open its IChannelListener. System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout) System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout) System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) System.ServiceModel.ServiceHostingEnvironment.HostingManager.ActivateService(String normalizedVirtualPath) System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) System.ServiceModel.ServiceHostingEnvironment.EnsureServiceAvailableFast(String relativeVirtualPath) System.ServiceModel.Activation.HostedHttpRequestAsyncResult.HandleRequest() System.ServiceModel.Activation.HostedHttpRequestAsyncResult.BeginRequest() System.ServiceModel.Activation.HostedHttpRequestAsyncResult.OnBeginRequest(Object state) System.ServiceModel.AspNetPartialTrustHelpers.PartialTrustInvoke(ContextCallback callback, Object state) System.ServiceModel.Activation.HostedHttpRequestAsyncResult.OnBeginRequestWithFlow(Object state) System.Runtime.IOThreadScheduler.ScheduledOverlapped.IOCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped) System.Runtime.Fx.IOCompletionThunk.UnhandledExceptionFrame(UInt32 error, UInt32 bytesRead, NativeOverlapped* nativeOverlapped) System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)

Respuesta

3

Bien, solucioné mi problema. El problema era que estaba bajo la impresión de que tenía que crear una carpeta segura en IIS y poner el archivo .svc allí para garantizar la transmisión de SSL. Resultó que no es el caso y todo lo que tuve que hacer fue usar el mismo archivo .svc y simplemente definir 2 puntos finales:

<endpoint address="http://localhost/Services/MyService.svc/MyService" 
      name="MyService" binding="wsHttpBinding" 
      bindingConfiguration="myWsHttpBinding" contract="Namespace.IMyService" /> 

<endpoint address="https://localhost/Services/MyService.svc/MySecureService" 
      name="MySslService" binding="basicHttpBinding" 
      bindingConfiguration="MySslServiceBinding" contract="Namespace.IMyService" /> 
1

Es posible que los directorios anidados confundan a IIS, tengo ha d esto sucede antes, aunque no en el contexto de WCF. Prueba a cambiar las direcciones de punto final a:

address="http://localhost/MyService" 
address="https://localhost/MySslService" 

¿Se puede probar que aloja la aplicación de una aplicación de consola en lugar de IIS? Estoy bastante seguro de que IIS está causando su problema de alguna manera, pero esto podría confirmarlo.

Si es posible, también trataría de aislar el problema eliminando algunos de los detalles de configuración, por ejemplo, bindingConfiguration y behaviorConfiguration.

Obviamente, estos son solo pasos de depuración que realizaría (puede que ya lo haya hecho) para tratar de aislar el problema, lo siento, no tengo una respuesta completa.

+0

Gracias. Lo intentaré mañana con una estructura no anidada aunque es un poco complicado con la forma en que están definidos y tengo que asegurar una carpeta, pero es posible. – Aliostad

+0

Podría ser más simple probar el concepto de carpeta anidada con un servicio ficticio en una VM: comience con algo que funcione y vea si puede romperlo :) –

+0

No tuve suerte como pensaba. Se desmorona en WCF no en IIS.De hecho, incluso encontré en el código MS donde falla usando Reflector pero no puedo averiguar exactamente cómo pasarlo. – Aliostad

Cuestiones relacionadas