【问题标题】:Orchard CMS WCF Service with ServiceRoute带有 ServiceRoute 的果园 CMS WCF 服务
【发布时间】:2012-10-05 20:26:59
【问题描述】:

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

Routes.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);
    }
}

ContentService.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 所写的 herehere,但似乎遗漏了一些东西。

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

【问题讨论】:

    标签: web-services orchardcms


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-11-03
      • 1970-01-01
      • 1970-01-01
      • 2011-07-26
      • 1970-01-01
      • 1970-01-01
      • 2011-07-25
      相关资源
      最近更新 更多