Orchard / MVC WCF Url de servicio con área

Bertrand creó un blogenvia para especificar cómo usar IoC en los módulos WCF para Orchard.

En 1.1, puede crear un archivo SVC utilizando la nueva fábrica de servidores Orchard:

<%@ ServiceHost Language="C#" Debug="true" 
    Service="MyModule.IMyService, MyAssembly"
    Factory="Orchard.Wcf.OrchardServiceHostFactory, Orchard.Framework" %>
Then register your service normally as an IDependency but with service and operation contract attributes:

using System.ServiceModel;

namespace MyModule {
    [ServiceContract]
    public interface IMyService : IDependency {
        [OperationContract]
        string GetUserEmail(string username);
    }
}

Mi pregunta es que todos los módulos de Orchard son realmente de área. Entonces, ¿cómo puede construir una ruta que llegue al archivo svc creado en el área / módulo?

¿Debería usar la ruta física completa para llegar al archivo svc (lo intenté y causó un problema web.config ya que estaba uniendo un sitio y un área).

http://localhost/modules/WebServices/MyService.svc

¿O crea una ruta de servicio con WebServiceHostFactory / OrchardServiceHostFactory?

new ServiceRoute("WebServices/MyService", new OrchardServiceHostFactory(), typeof(MyService))

Lo que sea que intente, obtengo un 404 cuando intento acceder al recurso. Pude hacer que esto funcionara utilizando un proyecto de aplicación wcf y configurando WCF como una aplicación independiente, mis problemas comenzaron cuando trataba de llevarlo a Orchard / MVC.

ACTUALIZA

Gracias por la ayuda Piotr,

Estos son los pasos que tomé para implementar el servicio.

Routes.cs

new RouteDescriptor {   Priority = 20,
                        Route = new ServiceRoute(
                                      "Services",
                                      new WebServiceHostFactory(),
                                      typeof(MyService)) }

Si uso OrchardServiceHostFactory () en lugar de WebServiceHostFactory () obtengo el siguiente error.

Operation is not valid due to the current state of the object.

Orchard Root Web.Config

  <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
    <standardEndpoints>
      <webHttpEndpoint>
        <!-- 
            Configure the WCF REST service base address via the global.asax.cs file and the default endpoint 
            via the attributes on the <standardEndpoint> element below
        -->
        <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true"/>
      </webHttpEndpoint>
    </standardEndpoints>
  </system.serviceModel>

MyService

[ServiceContract]
public interface IMyService : IDependency
{
    [OperationContract]
    string GetTest();
}

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
class MyService : IMyService
{
    public string GetTest()
    {
        return "test";
    }
}

No pude hacer que el servicio funcionara simplemente modificando web.config del módulo. Obtuve el siguiente erro

ASP.NET routing integration feature requires ASP.NET compatibility.

UPDATE 2

Orchard Root Web.Config

  <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
    <!-- ... -->
  </system.serviceModel>

Routes.cs

public IEnumerable<RouteDescriptor> GetRoutes() {
    return new[] {
                     new RouteDescriptor {   Priority = 20,
                                             Route = new ServiceRoute(
                                                 "Services",
                                                 new OrchardServiceHostFactory(),
                                                 typeof(IMyService))

                     }
                 };
}

Esto funciona, la clave aquí es que debe llamar typeof en el objeto que hace referencia a IDependency, WorkContextModule.IsClosingTypeOf no puede manejar el objeto que consume la dependencia, debe tomar la interfaz por la que se llama directamente.

Respuestas a la pregunta(1)

Su respuesta a la pregunta