WCF 서비스 모델을 사용하여 Siebel 어댑터를 사용하여 비즈니스 구성 요소에서 작업 실행
Siebel 비즈니스 구성 요소를 대상으로 하는 WCF 클라이언트를 만들 수 있습니다. 그런 다음 WCF 클라이언트를 사용하여 Siebel 시스템의 비즈니스 구성 요소에 대한 삽입, 업데이트, 쿼리, 삭제, 연결, 분리 및 자식 레코드 쿼리 작업을 수행할 수 있습니다. Siebel 비즈니스 개체는 어댑터 서비스 참조 Visual Studio 플러그 인 추가의 비즈니스 개체 노드 아래에 표시됩니다. 각 비즈니스 개체를 구성하는 비즈니스 구성 요소는 해당 개체에 해당하는 노드 아래에 표시됩니다. Siebel 어댑터를 사용하여 WCF 서비스 모델 개요의 단계에 따라 특정 작업을 대상으로 하는 비즈니스 구성 요소에 대한 WCF 클라이언트를 생성하고 클라이언트를 사용하여 비즈니스 구성 요소에서 이러한 작업을 호출할 수 있습니다.
참고
이 항목에서는 비즈니스 구성 요소에 대한 기본 작업(삽입, 업데이트, 쿼리, 삭제)을 수행하는 방법에 대한 정보를 제공합니다. 연결, 분리 및 자식 레코드 쿼리 작업을 수행하는 방법에 대한 자세한 내용은 WCF 서비스 모델을 사용하여 MVG 필드를 사용하여 비즈니스 구성 요소에 대한 작업 실행을 참조하세요.
다음 코드는 WCF 클라이언트를 사용하여 Account 비즈니스 개체의 계정 비즈니스 구성 요소에 있는 레코드에 대해 삽입, 업데이트 및 삭제 작업을 수행합니다. 각 작업 사이에 쿼리 작업이 수행되어 결과를 확인합니다. 이 예제의 WCF 클라이언트는 어댑터 서비스 참조 플러그 인 추가에서 생성된 구성 파일에서 초기화됩니다. 생성된 구성 파일의 예는 Siebel 시스템에 대한 WCF 클라이언트 구성을 참조하세요.
using System;
using System.Collections.Generic;
using System.Text;
using System.ServiceModel;
using microsoft.lobservices.siebel._2007._03.BusinessObjects;
using microsoft.lobservices.siebel._2007._03;
namespace Business_Component_Operations
{
class Program
{
static void Main(string[] args)
{
BusinessObjects_Account_Account_OperationClient client = null;
try
{
client = new BusinessObjects_Account_Account_OperationClient("SiebelBinding_BusinessObjects_Account_Account_Operation");
client.ClientCredentials.UserName.UserName = "YourUserName";
client.ClientCredentials.UserName.Password = "YourPassword";
Console.WriteLine("Opening connection to " + client.Endpoint.Address.Uri.Host);
client.Open();
AccountInsertRecord[] air = new AccountInsertRecord[1];
air[0] = new AccountInsertRecord();
Random r = new Random();
int count = r.Next();
air[0].Name = "Anil" + count.ToString();
Console.WriteLine("Inserting " + air[0].Name + " ...");
client.Insert(air);
//Query for the record.
Console.WriteLine("Querying to check inserted record ...");
AccountQueryInputRecord aqir = new AccountQueryInputRecord();
short viewmode = new short(); viewmode = 3;
string[] fields = new string[2];
fields[0] = "Name";
fields[1] = "Id";
aqir.QueryFields = fields;
aqir.SearchExpr = "[Name] LIKE \"Anil*\"";
AccountQueryRecord[] aqr = client.Query(viewmode, aqir);
Console.WriteLine(aqr.Length + " records returned");
string[] ids = new string[1];
AccountUpdateRecord[] aur = new AccountUpdateRecord[1];
aur[0] = new AccountUpdateRecord();
foreach (AccountQueryRecord rec in aqr)
{
Console.WriteLine("Name: " + rec.Name);
Console.WriteLine("Id: " + rec.Id);
Console.WriteLine("");
ids[0] = rec.Id;
aur[0].Name = rec.Name;
aur[0].Id = rec.Id;
}
//Update it.
aur[0].Name = "Anil" + count.ToString() + "modified";
Console.WriteLine("Update the record to " + aur[0].Name + " ...");
client.Update(viewmode, aur);
//query again
aqr = client.Query(viewmode, aqir);
Console.WriteLine(aqr.Length + " records returned");
foreach (AccountQueryRecord rec in aqr)
{
Console.WriteLine("Name: " + rec.Name);
Console.WriteLine("Id: " + rec.Id);
Console.WriteLine("");
}
//Delete it.
Console.WriteLine("Deleting record ...");
client.Delete(viewmode, ids, "");
//Check again.
Console.WriteLine("Check that " + aur[0].Name + " is not present");
aqr = client.Query(viewmode, aqir);
Console.WriteLine(aqr.Length + " records returned");
foreach (AccountQueryRecord rec in aqr)
{
Console.WriteLine(rec.Name);
Console.WriteLine(rec.Id);
}
// Wait for <RETURN> to end sample.
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();
}
}
}
}
}