Showing posts with label EAI. Show all posts
Showing posts with label EAI. Show all posts

Sunday, January 22, 2012

Understanding EAI Transaction Service

Recently I got the chance to work on a EAI requirement which requires the use of business service:  "EAI Transaction Service"

This post might help you if you are hearing this business service for the first time.

First of all, let me tell you what was the requirement for which I used this business service and later will tell you how it works.

Requirement
We have integration between a third-party system which keeps the Quotes, created in Siebel. So whenever a Quote record is UPDATED, it should also get reflect in the third-party system. The synchronous transaction is being send via real-time Web Service call at the WriteRecord event of Quote BC. The requirement was, while sending the updated Quote XML to the other system, check for the web service response. If the response = "Success", it is fine, but if response = "Failed", then revert back the changes done by user on the UI. So lets suppose user has changed 3-4 fields on Quote list applet and saved the record, and while integration call, system receives the respone = "Failed", then system has to revert back the values of these 3-4 fields.

Now, let us see how EAI Transaction Service help in this scenario:

I will not discuss the integration details but just the technical details related to EAI Transaction Service. Please assume that we already have a function: "SendToInterface()" created which will take care of sending the Quote XML to the other system. Now, here is what you need to do:

1. BusComp Server Script -> General -> Declarations:


var svcEAITransService = TheApplication().GetService("EAI Transaction Service");
var psInp = TheApplication().NewPropertySet();
var psOut = TheApplication().NewPropertySet();

2. BusComp_PreWriteRecord:


function BusComp_PreWriteRecord ()
{
svcEAITransService.InvokeMethod("BeginTransaction", psInp, psOut);
return (ContinueOperation);
}

3. BusComp_WriteRecord()


var strResult = SendToInterface();
psInp.Reset();
psOut.Reset();
if (strResult == "Failed")
psInp.SetProperty("Is Abort", "True");
svcEAITransService.InvokeMethod("EndTransaction", psInp, psOut);
this.InvokeMethod("RefreshRecord");




So, from the point you invoke "BeginTransaction" method, system keeps a check-point for you, till the time you invoke "EndTransaction" method. And as soon as EndTransaction get executed, the data gets commit actually to the database. 

Points to ponder:
  1. If BeginTransaction method has been executed, then execution of EndTransaction method is MUST for getting the data commit into the database. If for any reason, it not get executed or thin-client session get closed, data will never go to database.
  2. In the same session, the updated value is available for the Business Component and if you do a GetFieldValue in the current instance or try to fetch value via Integration Object, you will get the updated value.
  3. In case you have a Workflow Policy based on some field you have updated, it will only get trigger after the event of execution of method: EndTransaction.


Query
Somebody might come back and ask why should even I use this business service, why don't I just call the "SendToInterface()" function in PreWriteRecord event itself and check for the web service response right there? If success, then let the WriteRecord event fire else prompt a message using RaiseErrorText?

Clarification
Well, the above statement might sounds correct, but keep in mind EAI Siebel Adapter will run a separate query to fetch the data in SiebelMessage, so unless and until, the WriteRecord event fires (in the current session) it won't be able to get the updated values in SiebelMessage.

Hope this helps.



Monday, July 18, 2011

How to send email containing multiple child records data?

I am pretty sure you will find this post very interesting, if you ever get a requirement to send a email in HTML format and email should have the details of the child records(dynamic data) as well.

XSLT (XSL Transformation) can do wonders for this kind of requirement where the basic idea is to get data in XML hierarchy from Siebel (which you can easily do via EAI Siebel Adapter and convert it into XML) and apply the XSL transformations to get the HTML output. And as far as you know how to play with HTML and XSL, you can create any kind of email format that you like to see. All you need is to use EAI XSLT Service business service with method Transform.

Below picture might give you some idea of it:



To understand the concept, let suppose:
1. As soon as an Opportunity gets submitted, you are required to send an email to the Sales person to inform him.
2. Email should have the details of child records created under that Opportunity.
3. Email should have some kind of formatting so that it looks good and eye-catching.

You might be thinking what is a big deal in it and why should I even use the XSLT (new term for lot many people) for it? There is a simple reason behind it, there is NO OOB way available in Siebel (as far as I know) by which you can include the data from Child records (multiple) in the email.

Let me first show you the proof-of-concept and later we will discuss about the technical solution.
1. I have below opportunity created with 2 records of Opportunity Products.

2. It has also 3 Quote records created under it.

3. As soon as Opportunity get submitted, system is required to send the email to the sales person.
4. Here below is the email, I would like to receive:


If you find that interesting, keep reading for the technical details of it.


Pre-requisite
Please note that for this demo, I have used a Integration Object (Opportunity) based on Opportunity BO with having only 3 ICs configured: Opportunity, Opportunity Product and Quote. And include only those fields whose values are required in the final email, for eg: Oppty Name, Product Name, Net Price, Quote Name etc. (Please refer the first picture of this post, XML part)


Technical Solution
1. Call a Workflow (based on Opportunity BO) as soon as Opportunity gets submitted.
(Note: System will automatically pass the row_id of Opportunity to "Object Id" process property of the Workflow Process)
Here below is the WF snapshot.


2. Process Properties

3. Step Details:


Code for XSLTBuffer
<?xml version="1.0" encoding="UTF-16"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="/"><html><body><h2>You have got an Opportunity to act on:</h2><h4>Opportunity Name : <span style="color:#ff0000"><xsl:value-of select="ListOfOpportunity/Opportunity/Name"/></span></h4><h3>Here below are the Product Details:</h3><table border="1"><tr bgcolor="#9acd32"><th>Product</th><th>Quantity</th><th>Net Price</th><th>Revenue</th></tr><xsl:for-each select="ListOfOpportunity/Opportunity/ListOfOpportunityProduct/OpportunityProduct"><tr><td><xsl:value-of select="Product"/></td><td><xsl:value-of select="ProductQuantity"/></td><td><xsl:value-of select="ProductPrice"/></td><td><xsl:value-of select="Revenue"/></td></tr></xsl:for-each></table><h3>Here below are the Quote Details:</h3><table border="1"><tr bgcolor="#9acd32"><th>Quote Name</th><th>Revision</th><th>Status</th> </tr><xsl:for-each select="ListOfOpportunity/Opportunity/ListOfQuote2/Quote2"><tr><td><xsl:value-of select="Name2"/></td><td><xsl:value-of select="Revision"/></td><td><xsl:value-of select="Status"/></td></tr></xsl:for-each></table></body></html></xsl:template></xsl:stylesheet>

If you want to learn about XSLT more, then please refer the below link:
http://www.w3schools.com/xsl/

Thursday, July 15, 2010

How to create Inbound Web Service in Siebel?

In the last post, we talked about creating an Outbound Web Service in Siebel where we receives the WSDL file from other system and consume it into Siebel Tools to generate necessary artifacts.

Today I found a very nice tutorial for creating an Inbound Web Service in Siebel. In this post you will find how to publish the WSDL from Siebel and let the outside world do data manipulation inside Siebel.

You can easily find it at the below links:

http://st-curriculum.oracle.com/obe/fmw/soa_apps_integ/10g/10_132_siebel/siebel.htm

http://www.oracle.com/webfolder/technetwork/tutorials/obe/fmw/soa_apps_integ/10g/10_132_siebel/siebel.htm


At the end of above tutorial, you will be generating the WSDL file from Siebel thin client which need to provide to other system to test the Inbound Web Service you created. Please refer the following post for testing the WSDL:


Test WSDL


Tuesday, June 8, 2010

How to create Outbound Web Service in Siebel?

Today, lets talk about how we can invoke an Outbound Web Service from Siebel. In the last post we learned how to test the WSDL using SOAPUI and I will use the same WSDL today (CurrencyConverter.wsdl) as the sample wsdl in this post.

1. Import the WSDL into Siebel Tools.
Create New Object. File Menu -> New Object -> EAI -> Web Service



Select the WSDL file path



Business Service will get created with name "CurrencyConverter" and its method "CoversionRate"



ConversionRate method has got its Input/Output Arguments. The point to be notice here is the Integration Objects i.e. "ConversionRate" and "ConversionRateResponse". These are the external integration objects which defines the Request and Response XML of the Web Service.



If you query for Integration Object (Input): "ConversionRate", it will look like this:
and these are the two Input arguments of the Request XML of the Web Service.



Similarly, the Output IO will have a single output argument:



2. Create the UI. (Applet based on Opportunity BC)



3. Create Workflow to get the response from Web Service.






4. Call the Workflow from button click. To do this just create a BC User Prop on Opportunity BC

Named Method 1 : "Invoke", "INVOKESVC", "Opportunity", "Workflow Process Manager", "RunProcess", "'ProcessName'", "CurrencyConverter"

Where "Invoke" is Method Invoked from button on the opportunity applet.

5. Compile the objects and test.



After button click:




I am assuming that you are connected to internet while doing this test and this is how you can play with the live web service.

Tuesday, June 1, 2010

How to test a WSDL if it is working or not?

No matter if you are working in Siebel or not, if you are going to implement any Outbound Web Service, the first thing you wanna check if the WSDL file received from the 3rd party is working or not before you actually consume it and start the development.

Same is the case with Siebel Tools, you require to consume it in Siebel tools which will result in creation of Web Service (which is nothing but the business service of Class: CSSWSOutboundDispatcher) and its corresponding Integration Objects.

So, the best way is to have a 3rd party tools to quickly verify the response from the other system. I have came across lot many tools which solve this purpose but my favourite is SOAPUI and I really find it very handy for this purpose.

This post is related to the very first step that you do while creating the outbound web service. I have picked one WSDL freely available on "http://www.webservicex.net/WS/default.aspx"

Now, lets see how to do it step by step:

1. Save the WSDL from the following link:
http://www.webservicex.net/CurrencyConvertor.asmx?WSDL



2. Get the SOAPUI tools, available at the below link:
http://www.soapui.org/

3. Open SOAPUI and go to File Menu -> Preferences and make sure following check boxes should be unchecked.



4. Now open the WSDL, that you have saved in Step 1. File Menu -> New SOAPUI Project OR Press Crtl N





5. You will see "Currency Converter" Web Service and its associated method in the left (Navigator) panel. Double click on "Request 1". It will bring up the SOAP Request / Response page in the right panel. The request XML will look like this:



6. Input the necessary values in FromCurrecny and ToCurrency tags of the request XML and hit the Go Button. For Eg:



7. Here is the response XML I received:



8. This confirms that WSDL is correct and working fine.

We will see in the next post, how to implement an Outboound WebService in Siebel.

Stay Tuned !!

Monday, December 7, 2009

Error in Inbound Integration !!

Generally whenever you create a new Inbound Integration in Siebel, its a recommended practice that you get a new Database login created for it and that you can share with the other system for which you have created this inbound integration. I did the same thing, requested for a new DB login from our DBA and got it created. Before handing over to other party for use, I tried testing this newly created Inbound Integration via SOAPUI (the best ever client I came across for testing integrations). Imported the wsdl and when hit Go, I received the message saying :

The user-context could not be established. Something is wrong with the assigned primary position or login related repository objects. See additional error messages for more information.(SBL-DAT-00546)

and yes my reaction was "Oops, I forget to create a record for the DB user, that I am using for this Inbound Integration, in Administration - User screen". Okayy, let me do that. I created the record under "Employees" view, assigned the necessary position and responsibilities.

Now, lets try again invoking the inbound integation again from SOAPUI, again hit Go, this time I received the different one:

The user ID or password that you entered is incorrect. Please check the spelling
and try again.(SBL-UIF-00272)


hmmm....... I don't think, the username and password I used in the SOAP header is incorrect, so just to confirm it, I went to Oracle client and tried logging into the Siebel Database and I was able to login successfully, no issues. That means the problem is somewhere else.

The best part while working with Siebel is, as soon as you receive any error, just verify the respective logs and you will get the clue. So, the next step towards resolving this issue is just to check the EAI Object Manager log. I went to log folder and found there was an error message in it saying:

SBL-DAT-00587: An error occurred setting the default locale for the session.

This is something to be notice here that the Login credentials I am using is getting problem with creating a new session with Siebel. I think, I know the resolution for this but before actually use that lets double check it. I opened the Siebel thin-client URL and tried login into application instead and again I received the same error that Username/password is not correct. Also in Object Manager log, I found the instance of the same error which I found in EAI Object Manager log.

So, this only happens when SSE_ROLE has not been assigned to the designated user. For creating a session, every Siebel user should have this role assigned otherwise it won't be able to login even. To check which all roles/priviledges are assigned to the user, just login into the database with that user's login credentials and run the following query :

select * from user_role_privs
It will list all the roles for you and keep in mind that SSE_ROLE is required if you want to create a user session on Siebel Server either via Object Manager or EAI Object Manager.

So, I just asked my DBA to do the needful and now I think I am good, and yes I was able to invoke Inbound integration sucessfully. Now its the time when I can share these login credentials along with the WSDL to other party.
.