gpt4 book ai didi

tridion - 在模型中创建 Web 服务时出错

转载 作者:行者123 更新时间:2023-12-05 00:35:00 25 4
gpt4 key购买 nike

我正在尝试创建一个数据模型来使用我的 GUI 扩展,我创建了一个返回字符串的简单服务。我已经配置了 model.config 并在我的 web.config 中添加了以下条目

<services>
<service name="CMSExtensions.Model.Services.PublicationInfo" behaviorConfiguration="Tridion.Web.UI.ContentManager.WebServices.DeveloperBehavior">
<endpoint name="PublicationInfo" address="" behaviorConfiguration="Tridion.Web.UI.ContentManager.WebServices.AspNetAjaxBehavior" binding="webHttpBinding" bindingConfiguration="Tridion.Web.UI.ContentManager.WebServices.WebHttpBindingConfig" contract="CMSExtensions.Model.Services.PublicationInfo"/>
</service>
</services>

当我尝试直接在浏览器中运行此服务时,出现以下错误:

解析器错误消息:没有名为 'Tridion.Web.UI.ContentManager.WebServices.DeveloperBehavior' 的服务行为.

当我尝试通过 GUI 中的 JS 调用它时,我收到此错误:
Uncaught TypeError: Cannot call method 'GetPublicationData' of undefined
CMSExtensions.Popups.PublicationInfo._onExecuteButtonClickedPublicationInfo_v6.0.0.39607.0_.aspx:433
(anonymous function)PublicationInfo_v6.0.0.39607.0_.aspx:2
EventRegister.f.executeListenerPublicationInfo_v6.0.0.39607.0_.aspx:16
aPublicationInfo_v6.0.0.39607.0_.aspx:16
Tridion.ObjectWithEvents.processHandlersPublicationInfo_v6.0.0.39607.0_.aspx:14
Tridion.ObjectWithEvents.fireEventPublicationInfo_v6.0.0.39607.0_.aspx:14
Tridion.Controls.Button.onclickPublicationInfo_v6.0.0.39607.0_.aspx:428
Tridion.Controls.Button.onmouseupPublicationInfo_v6.0.0.39607.0_.aspx:428
(anonymous function)PublicationInfo_v6.0.0.39607.0_.aspx:2
EventRegister.f.executeListenerPublicationInfo_v6.0.0.39607.0_.aspx:16
a

我使用的是 SDL Tridion 2011(无 SP1)。

这是服务代码
 using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.ServiceModel.Web;
using CMSExtensions.Model.Progress;
using Tridion.Web.UI.Models.TCM54;


namespace CMSExtensions.Model.Services
{

[ServiceContract(Namespace = "http://CMSExtensions.Model.Services", Name = "PublicationInfo")]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]

public class PublicationInfo : WCFServiceBase
{
[OperationContract]
[WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json)]
public string GetUserDescription()
{
return "sachin";
}
}
}

模型配置:
<cfg:groups>
<cfg:group name="CMSExtensions.Model.Services" merger="Tridion.Web.UI.Core.Configuration.Resources.DomainModelProcessor" merge="always">
<cfg:domainmodel name="CMSExtensions.Model.Services">
<cfg:fileset>
<!-- <cfg:file type="script">/Scripts/Constants.js</cfg:file> -->
</cfg:fileset>

<cfg:services>
<cfg:service type="wcf">/Services/PublicationInfo.svc</cfg:service>
</cfg:services>
</cfg:domainmodel>
</cfg:group>
</cfg:groups>

Web.config 条目:
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="CMSExtensions.Model.Services.PublicationInfo" behaviorConfiguration="Tridion.Web.UI.ContentManager.WebServices.DeveloperBehavior">
<endpoint name="PublicationInfo" address="" behaviorConfiguration="Tridion.Web.UI.ContentManager.WebServices.AspNetAjaxBehavior" binding="webHttpBinding" bindingConfiguration="Tridion.Web.UI.ContentManager.WebServices.WebHttpBindingConfig" contract="CMSExtensions.Model.Services.PublicationInfo"/>
</service>
</services>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />

最佳答案

Tridion.Web.UI.ContentManager.WebServices.DeveloperBehavior 在 WebRoot 目录的 web.config 文件中定义。所以很可能你正试图在不同的应用程序(池)中运行它。

我建议确保您的模型和编辑器只是虚拟目录 IIS 而不是应用程序。

关于tridion - 在模型中创建 Web 服务时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9991654/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com