2012-04-03 42 views
4

我想創建一個數據模型以使用我的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" /> 
+0

你能分享你的網絡服務代碼和你的命令的JavaScript嗎?沒有這些,很難看到這裏出了什麼問題。 – 2012-04-03 11:01:51

+0

@FrankvanPuffelen - 只是添加了代碼片段。 – sachspeak 2012-04-03 16:22:37

+0

你可以修復該配置的縮進嗎?你可以在任何文本編輯器中做到這一點,它會使這裏的每個人都更易讀。 – 2012-04-03 16:58:41

回答

2

如果你正確地包含在模型中的配置自定義的Web服務文件將生成一個用於調用您的服務的JavaScript代理。您可以在Default.aspx?mode = js文件中找到生成的JavaScript代碼,您可以在瀏覽器的調試工具中找到它。

如果JavaScript代理不在那裏,請確保您已經增加了System.config中的更新數量。如果你已經這樣做了,代理仍然不顯示,請檢查生成的JavaScript和事件日誌中是否有錯誤消息。

4

Tridion.Web.UI.ContentManager.WebServices.DeveloperBehavior在WebRoot目錄的web.config文件中定義。所以很可能你試圖在不同的應用程序(池)中運行這個。

我建議確保您的模型和編輯器只是虛擬目錄IIS而不是應用程序。

+0

它被設置爲Vdir而不是Web應用程序。 – sachspeak 2012-04-03 16:23:06

+0

這很奇怪。它應該繼承它。你有沒有試過把行爲複製到你自己的web.config? – 2012-04-04 08:47:10