tl;博士
下面是我的类库中的 app.config,它简化了 SharePoint 中的文件操作。这些endpoint
地址指向任意站点,但在使用库时会动态设置为正确的站点。
如果任意地址更改/停止存在,DLL 是否仍然有效?
我可以打包我的类库以将endpoint
's 和binding
's动态添加到引用该库的项目中(基于他们与之交互的站点)吗?
细节
我在 C# 中创建了一个类库,以简化通过 Copy and Lists Web 服务访问 SharePoint 网站的过程。通过传入站点 URL 和其他数据,最终用户可以轻松地在 SharePoint 中上传、下载和操作文件。当他们传递站点 URL 时,我动态设置 Copy 或 Lists 引用以使用该 URL。虽然这很好,但我有两个问题:
我必须在 app.config/web.config 中包含对一台 SharePoint 服务器的引用,以便在开发时获取 Web 服务详细信息。如果该 URL 更改或不再存在,那么我的库会失败吗?
即使引用时包含 DLL,但不包含包含
basicHttpBinding
和endpoint
地址的 app.config。有没有办法在使用类库的项目的 web.config/app.config 中添加该数据?
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
</appSettings>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="CopySoap" maxReceivedMessageSize="419430400">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Ntlm" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
<binding name="ListsSoap">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Ntlm" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://www.example.com/subsite/_vti_bin/copy.asmx"
binding="basicHttpBinding" bindingConfiguration="CopySoap"
contract="CopyService.CopySoap" name="CopySoap" />
<endpoint address="http://www.example.com/subsite/_vti_bin/Lists.asmx"
binding="basicHttpBinding" bindingConfiguration="ListsSoap"
contract="ListsService.ListsSoap" name="ListsSoap" />
</client>
</system.serviceModel>
</configuration>
谢谢你的时间。