簡體   English   中英

在Tridion 2011 SP1 HR1中模擬核心服務

[英]Impersonate core service in Tridion 2011 SP1 HR1

我試圖冒充Tridion 2011 SP1 HR1中的核心服務,我收到此錯誤:

無法處理該消息,因為操作“http://www.sdltridion.com/ContentManager/CoreService/2011/ISessionAwareCoreService/Impersonate”無效或無法識別。

為什么會這樣? 我必須盲目不明白為什么它不起作用......

關於服務器:Tridion 2011 SP1 HR1的新安裝

我的代碼看起來像這樣:

 client = Client.GetCoreService();

 if (string.IsNullOrEmpty(username)) username = HttpContext.Current.User.Identity.Name;
      client.Impersonate(username);

這是GetCoreService方法:

public static SessionAwareCoreServiceClient GetCoreService()
{
       AppSettingsReader reader = new AppSettingsReader();

       string coreServiceUrl = (string)reader.GetValue("CoreServiceEndPoint", typeof(string));
       int dataSize = (int)reader.GetValue("DataSize", typeof(int));

       var quotas = new System.Xml.XmlDictionaryReaderQuotas
       {
           MaxStringContentLength = dataSize,
           MaxArrayLength = dataSize,
           MaxBytesPerRead = dataSize
       };

       var httpBinding = new WSHttpBinding
       {
           MaxReceivedMessageSize = 10485760,
           ReaderQuotas = quotas,
           Security = { Mode = SecurityMode.Message, Transport = { ClientCredentialType = HttpClientCredentialType.Windows } }
       };

       var endpoint = new EndpointAddress(coreServiceUrl);
       var result = new SessionAwareCoreServiceClient(httpBinding, endpoint);

       return result;
  }

從appsettings中提取(用“hostname”替換實際主機名):

<add key="CoreServiceEndPoint" value="http://hostname/WebServices/CoreService.svc/wsHttp_2010" />
<add key="DataSize" value="41943040" />

從開源項目中查看此示例以獲取您需要的通知

http://code.google.com/p/tridion-notification-framework/source/browse/NotificationService/NotificationService/CoreService/Client.cs

這是冒充的工作線

public static SessionAwareCoreServiceClient GetCoreService()
{
    var result = GetNewClient<SessionAwareCoreServiceClient>();


    result.Impersonate(ConfigurationManager.AppSettings.Get("adminUser"));
    return result;
}

另請參閱同一CS文件中的示例中創建客戶端的方式以及應用程序設置。 我認為您使用的是舊的端點地址,它應該是http://hostname/webservices/CoreService2011.svc/wsHttp而不是http://hostname/WebServices/CoreService.svc/wsHttp_2010

您正在連接到舊的Core Service wsHttp端點。

如果您使用的是2011 SP1客戶端,則需要連接到以下端點:

http://hostname/webservices/CoreService2011.svc/wsHttp

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM