我有一个Tridion核心服务Web应用程序来发布页面。登录到服务器并通过浏览器客户端使用ajax调用Web服务从那里运行它可以正常工作。但是,当我从桌面运行应用程序时,它什么都不做,并且不会抛出任何错误消息。
*编辑: 托管Web服务的Web应用程序在Tridion 2011 CMS网站下作为“应用程序”运行。这样做是为了避免跨域ajax问题/
我的代码是:
string binding = "wsHttp_2011";
using (var client = new SessionAwareCoreServiceClient(binding))
{
client.Impersonate("company\\cms_svc");
// ** Get Items to Publish
List<string> itemsToPublish = GetItemsToPublish(publishItem.TcmUri, client);
PublishInstructionData instruction = new PublishInstructionData
{
ResolveInstruction = new ResolveInstructionData() { IncludeChildPublications = false },
RenderInstruction = new RenderInstructionData()
};
PublicationTargetData pubtarget = (PublicationTargetData)client.Read(publishItem.PubTargetUri, readoptions);
List<string> target = new List<string>();
target.Add(pubtarget.Id);
client.Publish(itemsToPublish.ToArray(), instruction, target.ToArray(), GetPublishPriority(publishItem.Priority), readoptions);
}
答案 0 :(得分:4)
请查看SDL Live Content上的此页面,其中介绍了以不同用户身份进行连接的各种方案:
根据文档,您可能希望使用NetworkCredential建立您的核心服务连接,而不是模拟:
using (ChannelFactory<ISessionAwareCoreService> factory =
new ChannelFactory<ISessionAwareCoreService>("netTcp_2011"))
{
NetworkCredential networkCredential =
new NetworkCredential("username", "password", "domain");
factory.Credentials.Windows.ClientCredential = networkCredential;
ISessionAwareCoreService client = factory.CreateChannel();
Console.WriteLine(client.GetCurrentUser().Title);
}