0

我已经配置了一个 Orchard 模块来公开服务并启用它。我无法根据以下内容计算出要使用的 URL。

路由.cs

namespace OrchardRestService
{
    using System.Collections.Generic;
    using System.ServiceModel.Activation;

    using Orchard.Mvc.Routes;
    using Orchard.Wcf;

    public class Routes : IRouteProvider
    {
        #region Implementation of IRouteProvider

        public IEnumerable<RouteDescriptor> GetRoutes()
        {
            return new[] {
                new RouteDescriptor {
                   Priority = 20,
                        Route = new ServiceRoute(
                                      "ContentService",
                                      new OrchardServiceHostFactory(),
                                      typeof(IContentService))
                }
            };
        }

        public void GetRoutes(ICollection<RouteDescriptor> routes)
        {
            foreach (var routeDescriptor in GetRoutes())
                routes.Add(routeDescriptor);
        }

        #endregion
    }
}

IContentService.cs:

namespace OrchardRestService
{
    using System.ServiceModel;

    using Orchard;

    [ServiceContract]
    public interface IContentService : IDependency
    {
        [OperationContract]
        ContentResult GetContent(string contentPath);
    }
}

内容服务.cs:

namespace OrchardRestService
{
    using System.Collections.Generic;
    using System.ServiceModel.Activation;

    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class ContentService : IContentService
    {
        public ContentResult GetContent(string contentPath)
        {
            var contentResult = new ContentResult
                { ContentValues = new Dictionary<string, string>(), Found = true, Path = contentPath };
            return contentResult;
        }
    }
}

我试图遵循 Bertrand Le Roy 在这里这里所写的内容,但似乎遗漏了一些东西。

顺便说一下,我的代码是 .Net 4,所以不需要 SVC 文件。

4

1 回答 1

1

关闭,因为我会跳过箍以这种方式使用 N2,而不是它的设计用途。

于 2012-10-05T12:26:59.670 回答