URL do serviço WCF do Orchard / MVC com área

Bertrand criou um blogposta para especificar como usar a IoC nos módulos WCF para Orchar

Na 1.1, você pode criar um arquivo SVC usando a nova fábrica de host do 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);
    }
}

Minha pergunta é que todos os módulos do Orchard são realmente da área. Então, como você pode criar uma rota que atinja o arquivo svc criado na área / módulo?

Você deve usar o caminho físico completo para acessar o arquivo svc (tentei isso e causou um problema no web.config, pois estava conectando um site e uma área

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

Ou você cria uma ServiceRoute com WebServiceHostFactory / OrchardServiceHostFactory?

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

Tudo o que eu tento, recebo um 404 ao tentar acessar o recurso. Consegui fazer isso funcionar usando um projeto de aplicativo wcf e definindo o WCF como um aplicativo independente; meus problemas começaram ao tentar trazê-lo para o Orchard / MVC.

ATUALIZA

Obrigado pela ajuda Piotr,

Este é o passo que tomei para implementar o serviç

Routes.cs

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

Se eu usar OrchardServiceHostFactory () em vez de WebServiceHostFactory (), obtenho o seguinte erro.

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";
    }
}

Não pude obter o serviço funcionando apenas modificando o web.config do módulo. Estou tendo o erro a segui

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))

                     }
                 };
}

Isso funciona, a chave aqui é que você deve chamar typeof no objeto que faz referência a IDependency, WorkContextModule.IsClosingTypeOf não pode manipular o objeto que consome a dependência, deve usar a Interface pela qual é chamado diretamente.

questionAnswers(1)

yourAnswerToTheQuestion