我想创建一个数据模型以使用我的GUI扩展,我创建了一个返回字符串的简单服务。我已经配置了model.config并加入我的web.config以下条目在模型中创建Web服务时出错
<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'
的服务行为。
,当我尝试调用它通过JS在GUI我得到这个错误:
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" />
你能分享你的网络服务代码和你的命令的JavaScript吗?没有这些,很难看到这里出了什么问题。 – 2012-04-03 11:01:51
@FrankvanPuffelen - 只是添加了代码片段。 – sachspeak 2012-04-03 16:22:37
你可以修复该配置的缩进吗?你可以在任何文本编辑器中做到这一点,它会使这里的每个人都更易读。 – 2012-04-03 16:58:41