为 Siebel 系统配置 WCF 客户端

生成 WCF 客户端类后,可以) 创建 WCF 客户端 (实例,并调用其方法来使用 Siebel 适配器。 有关如何为适用于 Siebel eBusiness 应用程序的 Microsoft BizTalk 适配器公开的操作生成 WCF 客户端类和帮助程序代码的信息,请参阅 为 Siebel 解决方案项目生成 WCF 客户端或 WCF 服务协定

若要创建 WCF 客户端,必须指定终结点地址和绑定。 终结点地址必须包含有效的 Siebel 连接 URI,并且绑定必须是 Siebel 绑定 (SiebelBinding) 的实例。 有关 Siebel 连接 URI 的详细信息,请参阅 在 Visual Studio 中连接到 Siebel 系统

可以在代码或配置文件中指定 Siebel 绑定和终结点地址。 使用添加适配器服务参考 Visual Studio 插件生成 WCF 客户端类时,还会为项目创建配置文件 (app.config) 。 此文件包含的配置设置反映绑定属性和连接信息 (,但凭据) 使用添加适配器服务引用插件连接到 Siebel 系统时指定的凭据除外。

在代码中指定绑定和终结点地址

以下代码演示如何通过在代码中指定绑定和终结点地址来创建 WCF 客户端。 最好是使用 WCF 客户端的 ClientCredentials 属性指定 Siebel 凭据,而不是在为终结点地址提供的连接 URI 中指定 Siebel 凭据。

// A WCF client that targets the TimeStamp business service is created  
// by using a binding object and endpoint address  
SiebelBinding sblBinding = new SiebelBinding();  
EndpointAddress sblAddress = new EndpointAddress("siebel://Siebel_server:1234?SiebelObjectManager=obj_mgr&SiebelEnterpriseServer=ent_server&Language=enu");  
  
BusinessServices_TimeStamp_OperationClient client =   
    new BusinessServices_TimeStamp_OperationClient(sblBinding, sblAddress);  
  
    client.ClientCredentials.UserName.UserName = "SADMIN";  
    client.ClientCredentials.UserName.Password = "SADMIN";  
  
    client.Open();  

在配置文件中指定绑定和终结点地址

以下代码演示如何通过在 app.config 文件中指定绑定和终结点地址来创建 WCF 客户端。

// A WCF client that targets the TimeStamp business service is created  
// by specifying the client endpoint information in app.config  
BusinessServices_TimeStamp_OperationClient client =   
    new BusinessServices_TimeStamp_OperationClient("SiebelBinding_BusinessServices_TimeStamp_Operation");  
  
client.ClientCredentials.UserName.UserName = "SADMIN";  
client.ClientCredentials.UserName.Password = "SADMIN";  
  
client.Open();  

App.config 文件

以下 XML 显示通过添加适配器服务引用插件为 TimeStamp 业务服务创建的配置文件。 此文件包含前面示例中引用的客户端终结点配置。

<?xml version="1.0" encoding="utf-8"?>  
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">  
    <system.serviceModel>  
        <bindings>  
            <siebelBinding>  
                <binding name="SiebelBinding" closeTimeout="00:01:00" openTimeout="00:01:00"  
                    receiveTimeout="00:10:00" sendTimeout="00:01:00" enableBizTalkCompatibilityMode="false"  
                    enablePerformanceCounters="false" enableConnectionPooling="true"  
                    maxConnectionsPerSystem="5" idleConnectionTimeout="00:01:00"  
                    acceptCredentialsInUri="false" />  
            </siebelBinding>  
        </bindings>  
        <client>  
            <endpoint address="siebel://Siebel_server:1234?SiebelObjectManager=obj_mgr&SiebelEnterpriseServer=ent_server&Language=enu"  
                binding="siebelBinding" bindingConfiguration="SiebelBinding"  
                contract="BusinessServices_TimeStamp_Operation" name="SiebelBinding_BusinessServices_TimeStamp_Operation" />  
        </client>  
    </system.serviceModel>  
</configuration>  

如果项目有多个 WCF 客户端,配置文件中将定义多个客户端终结点条目。 每个 WCF 客户端条目将根据其绑定配置和目标 Siebel 项目具有唯一的名称;例如“SiebelBinding_BusinessServices_TimeStamp_Operation”。 如果多次连接以在项目中创建 WCF 客户端,则会创建多个绑定配置条目,每个连接一个绑定配置条目。 这些绑定配置条目将按以下方式命名:SiebelBinding、SiebelBinding1、SiebelBinding2 等。 在特定连接期间创建的每个客户端终结点条目都将引用在该连接期间创建的绑定项。

另请参阅

使用 WCF 服务模型开发 Siebel 应用程序