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

And*_*mon 8 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);
Run Code Online (Sandbox Code Playgroud)

这是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;
  }
Run Code Online (Sandbox Code Playgroud)

从appsettings中提取(用"hostname"替换实际主机名):

<add key="CoreServiceEndPoint" value="http://hostname/WebServices/CoreService.svc/wsHttp_2010" />
<add key="DataSize" value="41943040" />
Run Code Online (Sandbox Code Playgroud)

Gou*_*CMS 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;
}
Run Code Online (Sandbox Code Playgroud)

另请参阅同一CS文件中的示例中创建客户端的方式以及应用程序设置.我认为你使用的是旧的端点地址,应该是http://hostname/webservices/CoreService2011.svc/wsHttp而不是http://hostname/WebServices/CoreService.svc/wsHttp_2010