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

在Tridion 2011 SP1 HR1中模拟核心服务,tridion,tridion-2011,Tridion,Tridion 2011,我试图在Tridion 2011 SP1 HR1中模拟核心服务,但出现以下错误: 无法处理该消息,因为操作失败 'http://www.sdltridion.com/ContentManager/CoreService/2011/ISessionAwareCoreService/Impersonate“”无效或无法识别 为什么会发生这种情况?我必须瞎了眼才能看不出它为什么不起作用 关于服务器:Tridion 2011 SP1 HR1的新安装 我的代码如下所示: client=client.Get

我试图在Tridion 2011 SP1 HR1中模拟核心服务,但出现以下错误:

无法处理该消息,因为操作失败 'http://www.sdltridion.com/ContentManager/CoreService/2011/ISessionAwareCoreService/Impersonate“”无效或无法识别

为什么会发生这种情况?我必须瞎了眼才能看不出它为什么不起作用

关于服务器:Tridion 2011 SP1 HR1的新安装

我的代码如下所示:

client=client.GetCoreService();
如果(string.IsNullOrEmpty(username))username=HttpContext.Current.User.Identity.Name;
client.Impersonate(用户名);
这是GetCoreService方法:

public静态SessionAwareCoreServiceClient GetCoreService()
{
AppSettingsReader reader=新的AppSettingsReader();
string coreServiceUrl=(string)reader.GetValue(“CoreServiceEndPoint”,typeof(string));
intdatasize=(int)reader.GetValue(“dataSize”,typeof(int));
var quotas=new System.Xml.XmlDictionaryReaderQuotas
{
MaxStringContentLength=数据大小,
MaxArrayLength=数据大小,
MaxBytesPerRead=数据大小
};
var httpBinding=新的WSHttpBinding
{
MaxReceivedMessageSize=10485760,
ReaderQuotas=配额,
安全性={Mode=SecurityMode.Message,传输={ClientCredentialType=HttpClientCredentialType.Windows}
};
var端点=新端点地址(coreServiceUrl);
var result=new SessionAwareCoreServiceClient(httpBinding,端点);
返回结果;
}
从appsettings中提取(将实际主机名替换为“主机名”):


从一个开放源代码项目中查看此示例,以获取您需要的通知

这是模拟的工作线

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


    result.Impersonate(ConfigurationManager.AppSettings.Get("adminUser"));
    return result;
}
public静态SessionAwareCoreServiceClient GetCoreService()
{
var result=GetNewClient();
模拟(ConfigurationManager.AppSettings.Get(“adminUser”);
返回结果;
}

还可以查看在同一个CS文件的示例中创建客户端的方式,以及应用程序设置。我认为您使用的是旧的端点地址,它应该是
http://hostname/webservices/CoreService2011.svc/wsHttp
而不是
http://hostname/WebServices/CoreService.svc/wsHttp_2010

您正在连接到旧的核心服务wsHttp端点

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

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