使用 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 应用程序