gpt4 book ai didi

linqpad - 有人使用 LINQPad 连接到 Tridion Core Services 吗?

转载 作者:行者123 更新时间:2023-12-02 07:25:34 25 4
gpt4 key购买 nike

我爱LINQPad !我正在尝试使用 LINQPad 中的 WCF 连接器连接到 Tridion Core Services,以帮助我快速开发和学习 Core。

当前,LINQPad 报告 URI 的 404(未找到)错误,但相同的 URI 在我的浏览器中有效。

还有人成功连接吗?

LINQPad的连接窗口

LINQPad's connection window

最佳答案

LINQPad 现在是我通过其核心服务 API 与 Tridion 交互的首选工具。

如果你只是download a plain LINQPad ,它可以连接到 WCF 数据服务(通常称为 OData 源)、SQL Server 数据库和 Azure 数据服务市场。由于 Tridion 的核心服务不是这些类型,因此您无法创建到它的持久连接。

但是您仍然可以按照以下步骤使用 LINQPad 作为 Visual Studio 的轻量级替代方案:

  1. 将 LINQPad 的语言切换为“C# 程序”
  2. 粘贴下面的代码片段
  3. 从代码片段中添加必要的 DLL 引用
  4. 从代码片段中添加必要的命名空间引用
  5. 指定您自己的主机名、用户名和密码值
  6. 编写代码

LINQPad 可以处理多种语言。它默认为“C# 表达式”,这意味着您只需在代码面板中指定单个“语句”。当与例如一起工作时,这非常有用。 SQL 数据库有可用的驱动程序,但不足以与 Tridion 的核心服务交互。因此,首先您需要在查询顶部的工具栏中将其从“C# 表达式”语言切换为“C# 程序”语言。

切换语言后,我通常从以下样板开始

void Main()
{
// System.Runtime.Serialization.dll
// System.ServiceModel.dll
// System.Net.dll
// Namespaces:
// System.Net
// System.ServiceModel
// Tridion.ContentManager.CoreService.Client
var binding = new NetTcpBinding { MaxReceivedMessageSize = 2147483647, ReaderQuotas = new XmlDictionaryReaderQuotas { MaxStringContentLength = 2147483647, MaxArrayLength = 2147483647 } };
var endpoint = new EndpointAddress("net.tcp://<hostname>:2660/CoreService/2011/netTcp");
var DEFAULT_READ_OPTIONS = new ReadOptions();

CoreServiceClient client = new CoreServiceClient(binding, endpoint);
client.ChannelFactory.Credentials.Windows.ClientCredential = new NetworkCredential("<username>", "<password>");
try {
// TODO: fill in the blanks
} finally {
if (client.State == CommunicationState.Faulted) client.Abort(); else client.Close();
}
}

粘贴此代码后,打开“查询属性”窗口 (F4) 并添加 System.Runtime.Serialization.dll , System.ServiceModel.dllSystem.Net.dll到附加引用选项卡。确保您的计算机上有 Tridion.ContentManager.CoreService.Client.dll 的副本,并添加对其的引用。 (您可以在服务器上的 Tridion/bin/client 中找到它)

添加System.Net , System.ServiceModelTridion.ContentManager.CoreService.Client到“其他命名空间导入”选项卡。

更改 <hostname> , <username><password>代码中的值并测试连接是否成功。

之后,填写空白并开始享受核心服务 API 的乐趣。

我建议始终保持核心服务 API 文档(CHM 格式)开放。打开后,我发现即使没有自动完成功能,我也能走得很远。如果保存刚刚创建的查询,则可以使用 ctrl-shift-C 轻松克隆它,并获得一个已填充语言、DLL 引用和命名空间的新查询。

更新

现在记录了从 LINQPad 连接到 Tridion 的更简单方法:https://sdltridionworld.com/articles/sdltridion2011/using_linqpad_with_tridion.aspx

关于linqpad - 有人使用 LINQPad 连接到 Tridion Core Services 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9670953/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com