Sunday 26 January 2020

Working with XML Document in Siebel CRM -- Use of REST

Hello All,

Recently i had a requirement wherein I had to insert some records in siebel with input as XML Document and all this was to be done over REST web service.

There are 2 parts to this
  1. Inserting record from XML Document
  2. Expose the Business Service over REST (available only IP 16+)

Part 1, can be divided in further sub-parts 

  •  Get XML Doc as Input and Convert XML Hierarchy to Siebel IO Hierarchy
   BS: EAI XML Converter
   Method: XMLDocToIntObjHier
   Input: XML Documment (containg our target records, the type of Process property should be String)


  • Pass the Hierarchy (output) from previous step as input in EAI Siebel Adapter


    BS: EAI Siebel Adapter
    Method: Upsert
    Input: Hierarchy (Output of previous step)

Part 2, to expose a BS as REST web service (inbound) follow the below steps

  • Make entry for the Business Service in Administration - Application --> Business Service Access
  • In the Access By Responsibilty section add the Responsibilty that needs to have access to this BS

Now you may think what different have we done in the above step, we created workflow as usual, so where is REST part??

Well siebel after IP 16, has a new architecture for REST, which can be explained as

1. Expose data using BO and BC Architecture (IO/IC)
http://ServerName:port/siebel-rest/v1.0/data/Account/Account/88-4XVPD

Here the keyword /data/ specify the use of BO/BC architecture , i.e the above line translates to "search for Account Record with Id 88-4XVPD in Account BC and Account BO"

2. Expose data using Business Service Architecture
http://ServerName:port/siebel-rest/v1.0/service/Siebel Account/QueryByExample

Here the keyword /service/ specify the use of Business Service architecture , i.e the above line translates to "Execute the QueryByExample of Business Service Siebel Account"

Note* this is just a high level detail , there are various other considerations like Methods (POST, GET, PUT) Headers, Body that need to be passed , will cover those in separate post
for a better understanding refer bookshelf https://docs.oracle.com/cd/E74890_01/books/PDF/RestAPI.pdf


Since we have to expose the Process Over REST, lets try to do this.

1. Following the generic Siebel Rest Architecture for Exposing Business Service over REST, we will use the URL:

URLhttps://hostname/siebel/v1.0/service/REST Test Service/ContactUpsert

Method: POST (BS uses post method to execute a action )

Body:
{
"body":
{
"XML":"<?xml version='1.0' encoding='UTF-16'?><SiebelMessage  MessageId='1-1LYUKZH'  MessageType='Integration Object'  IntObjectName='Contact Integration Object'  IntObjectFormat='Siebel Hierarchical' ><ListOfContactIntegrationObject><Contact><Id>1-1122121</Id><FirstName>Sheename</FirstName> <LastName>Rawal</LastName><EmailAddress>Verma@gmail.com</EmailAddress></Contact><Contact><Id>1-1122122</Id><FirstName>Sajan</FirstName><LastName>kumar</LastName><EmailAddress>sheenam@gmail.com</EmailAddress></Contact></ListOfContactIntegrationObject></SiebelMessage>"
}
}

 
Here in "body", we have the input process property "XML" that will accept XML string as input. (this is standard input way to be used in REST URL calls)


*Sample output on postman tools for testing the BS


Now we have the Workflow ready, let us write a simple BS to accept XML document as input and expose it over REST.

Client BS to call workflow :

function Service_PreInvokeMethod (MethodName, Inputs, Outputs)
{
/*var XML = "<?xml version='1.0' encoding='UTF-16'?><SiebelMessage  MessageId='1-1LYUKZH'  MessageType='Integration Object'  IntObjectName='Contact Integration Object'  IntObjectFormat='Siebel Hierarchical' ><ListOfContactIntegrationObject><Contact><Id>1-1122121</Id><FirstName>Sharma</FirstName> <LastName>Sharma</LastName><EmailAddress>sharma@gmail.com</EmailAddress></Contact></ListOfContactIntegrationObject></SiebelMessage>";*/

var XML = Inputs.GetProperty('XML');

var sSvc = TheApplication().GetService('Workflow Process Manager');

var sInputs = TheApplication().NewPropertySet();

var sOutputs = TheApplication().NewPropertySet();

sInputs.SetProperty('XML Doc',XML);

sInputs.SetProperty('ProcessName','HHML XML Doc to Hierarchy');

sSvc.InvokeMethod('RunProcess', sInputs, sOutputs);

Outputs.SetProperty('MSG',"Done");

return (CancelOperation);
}




sample Input XML:

<?xml version='1.0' encoding='UTF-16'?>
<SiebelMessage  MessageId='1-1LYUKZH'  MessageType='Integration Object'  IntObjectName='Contact Integration Object'  IntObjectFormat='Siebel Hierarchical' >
<ListOfContactIntegrationObject>
<Contact>
<Id>1-1122121</Id>
<FirstName>Sharma</FirstName>
<LastName>Sharma</LastName>
<EmailAddress>sharma@gmail.com</EmailAddress>
</Contact>
</ListOfContactIntegrationObject>
</SiebelMessage>


Siebel GoTo View - Handling Realtime cases

 Hello All,  We all must have used GoTo view functionality of siebel to navigate to a particular view from current view. What if the require...