共用方式為


使用 WCF 服務模型搭配 Siebel 配接器叫用商務服務方法

您可以建立以 Siebel 商務服務方法為目標的 WCF 用戶端。 接著,您可以使用 WCF 用戶端在 Siebel 系統上叫用這些方法。 Siebel 商務服務會顯示在 [新增配接器服務參考 Visual Studio 外掛程式] 的 [商務服務] 節點底下。 每個商務服務所公開的方法都會顯示在對應至該服務的節點底下。 您可以使用 Siebel 配接器遵循 WCF 服務模型 概觀中的步驟,為商務服務產生 WCF 用戶端,並用它來叫用服務的方法。

下列程式碼會使用 WCF 用戶端叫用 TimeStamp 商務服務的 Execute 方法。 時間戳記會在 Siebel 伺服器的當地時間傳回,然後寫入主控台。 此範例中的 WCF 用戶端是從新增配接器服務參考外掛程式所產生的組態檔初始化。 如需所產生組態檔的範例,請參閱 設定 Siebel 系統的 WCF 用戶端

using System;  
using System.Collections.Generic;  
using System.Text;  
  
using System.ServiceModel;  
using microsoft.lobservices.siebel._2007._03.BusinessServices.TimeStamp;  
  
namespace Business_Service  
{  
    class Program  
    {  
        static void Main(string[] args)  
        {  
            BusinessServices_TimeStamp_OperationClient client = null;  
  
            try  
            {  
                client =  
                     new BusinessServices_TimeStamp_OperationClient("SiebelBinding_BusinessServices_TimeStamp_Operation");  
  
                client.ClientCredentials.UserName.UserName = "YourUserName";  
                client.ClientCredentials.UserName.Password = "YourPassword";  
                client.Open();  
  
                ExecuteResponseRecord er = client.Execute();  
                Console.WriteLine(er.Time);  
  
                Console.WriteLine("\nHit <RETURN> to finish");  
                Console.ReadLine();  
            }  
            catch (Exception e)  
            {  
                Console.WriteLine(e.Message);  
            }  
            finally  
            {  
                // Close the client.  
                if (client != null)  
                {  
                    if (client.State == CommunicationState.Opened)  
                        client.Close();  
                    else  
                        client.Abort();  
                }  
            }  
        }  
    }  
}  

另請參閱

使用 WCF 服務模型開發 Siebel 應用程式