我正在尝试在 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 中提取(将实际主机名替换为“主机名”):
<add key="CoreServiceEndPoint" value="http://hostname/WebServices/CoreService.svc/wsHttp_2010" />
<add key="DataSize" value="41943040" />