在Tridion 2011 SP1 HR1中模拟核心服务

时间:2012-12-12 09:50:13

标签: tridion tridion-2011

我试图冒充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" />

2 个答案:

答案 0 :(得分:6)

从开源项目中查看此示例以获取您需要的通知

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

答案 1 :(得分:3)

您正在连接到旧的Core Service wsHttp端点。

如果您使用的是2011 SP1客户端,则需要连接到以下端点:

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