針對 Siebel 系統設定 WCF 用戶端
產生 WCF 用戶端類別之後,您可以建立 WCF 用戶端 (實例) ,並叫用其方法來取用 Siebel 配接器。 如需如何針對 Microsoft BizTalk Adapter for Siebel eBusiness Applications 公開的作業產生 WCF 用戶端類別和協助程式程式程式碼的資訊,請參閱 產生 WCF 用戶端或 Siebel 解決方案成品的 WCF 服務合約。
若要建立 WCF 用戶端,您必須指定端點位址和系結。 端點位址必須包含有效的 Siebel 連線 URI,而且系結必須是 Siebel Binding 的實例, (SiebelBinding) 。 如需 Siebel 連線 URI 的詳細資訊,請參閱 連線到 Visual Studio 中的 Siebel 系統。
您可以在程式碼或組態檔中指定 Siebel 系結和端點位址。 當您使用 [新增配接器服務參考 Visual Studio 外掛程式] 來產生 WCF 用戶端類別時,也會為您的專案建立組態檔 (app.config) 。 此檔案包含組態設定,這些組態設定會反映系結屬性和連線資訊 (,但當您使用 [新增配接器服務參考外掛程式] 連接到 Siebel 系統時所指定的) 認證除外。
在程式碼中指定系結和端點位址
下列程式碼示範如何在程式碼中指定系結和端點位址來建立 WCF 用戶端。 最好是使用 WCF 用戶端的 ClientCredentials 屬性來指定 Siebel 認證,而不是在為端點位址提供的連線 URI 中指定。
// 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 等等。 在特定連接期間建立的每個用戶端端點專案都會參考在該連接期間建立的系結專案。