Showing posts with label OSB. Show all posts
Showing posts with label OSB. Show all posts

Thursday, 28 January 2016

Connect and consume data assets with OSB12c and WebCenter Sites 11g using the REST api


In one of the project I've worked on, I configured an automatic creation/update and delete of assets in WebCenter Sites 11g using its REST api via OSB.

The configuration is a bit tricky so I want to share the solution.

I am not giving the details step by step of how this can be implemented as I am sharing the code, btw I'll explain the main important concept.

What it is needed for this tip:

  • JDeveloper 12.1.3 (SOA Quick start version)
  • An account with read/write right permission in a WebCenter Sites server
  • The AssetType created in Sites

OSB Services Implemented

The Pipeline in the project contains the below services:

XSLT NameWCSites Component used Relative URIHTTP Operation
getTicketAuthorizationcas/v1/ticketsGET 
getCourseIdByCodeCustom Asset Course<SITE NAME>/types/<ASSET NAME>/searchGET
getSessionIdByCodeCustom Asset Session<SITE NAME>/types/<ASSET NAME>/searchGET
getContentIdByNameAsset Generic<SITE NAME>/types/<ASSET NAME>/searchGET
getParentIdByIdAsset Generic<SITE NAME>/types/<ASSET NAME>/assetsGET
createUpdateCourseAsset Course<SITE NAME>/types/<ASSET NAME>/assetsPOST
createUpdateCourseParentAsset Generic<SITE NAME>/types/<ASSET NAME>/assetsPOST
createUpdateSessionCustom Asset Session<SITE NAME>/types/<ASSET NAME>/assetsPOST
isCourseSessionReadyAsset Course<SITE NAME>/types/<ASSET NAME>/assetsGET
isSessionDifferentCustom Asset Session<SITE NAME>/types/<ASSET NAME>/assetsGET
deleteSessionCustom Asset Session<SITE NAME>/types/<ASSET NAME>/assetsDELETE

Below are some important point to highlight:

  • To get an authentication token for WcSites 11 the endpoint http://HOST:PORT/cas/v1/tickets has to be called twice. First time with username and password in the body of a POST, while the second time with the ticket in the Url of the request. Please note that this "service" does not return XML, but HTML therefore this has to be parsed with OSB.
  • All the http POST/DELETE methods on WcSites must be called with the parameter Multiticket in the url
<http:parameter name="multiticket" value="<ticket>">
</http:parameter>
  • The Search method uses an url parameter as below. Please note the search against a specific parameters has to be enabled in Sites first:
<http:parameter name="field:name:equals" value="<CODE VALUE>">
</http:parameter>

Possible problems

  • In case the REST api invocation fails with this:
"OSB-38000 BAD Gateway "

Then uncheck in the OSB Business Service the Chunked mode and redeploy it!


  • In case the WebService invocation fails with this:
"MOVED TEMPORALLY"

Then the credential account is not configured correctly in OSB or the process can't see it. Review it!
Tip: By default, if an authorization failure occurs, the login page for Central Authentication Service (CAS) is displayed. If you want to receive a 500 error instead, add auth-redirect=false to the URL when making the request.

Please find the REST api documentation here!
The source code of the OSB pipeline created here

Saturday, 22 November 2014

SOA11 and Coherence integration case study

In one of the project where I've worked on, the customer was facing issues due to the many web services calls triggered by their portal. Basically the Service Bus was crashing since it was reaching its limit in terms of web services transactions supported.

The initial architecture



The logged in users in Web Center portal were triggering calls trough the ADF framework to the OSB, and those calls were validated and enriched and then routed to the target third party services. All those operation were synchronous.

The analysis

We decided to take a deeper look to understand which services were being called, how many times and with which frequency, etc.
The tool we used here, was the Statistics in the OSB. We enabled them on all the Web Services, we run the Portal, and played with the functionality, which were calling the WS under analysis.

After 10 minutes we got the following result, where we noted 2 main things:

  1. There were some WS operations called very frequently (1 each 20 msecs for each logged users) like GetTask and GetCurrentState, while all the others were being called only few times.
  2.  The WS calls were getting information only for the specified WC Portal user which was triggering theggering thise calls.




The Solution

We spoke with the developers of the third party WS, proposing them to move to a "bundle" approach. Basically we asked them to expose two more operations, GetBundleTask and GetBundleState, which respectively were like GetTask and GetCurrentState, but with a list of usersId/taskId in input.
We configured a new Coherence server, thinking about using an asynchronous approach and the caching of the data. The architecture now looks like this:


Benefits:
  • The WebCenter/ADF layer did not need any modification since we did not touch the OSB WS interfaces.
  • The SOA Async process was getting data in bundle for all the Users logged in in one call (or very few) with much better results.
  • The services exposed on the OSB were getting the data 99% of the time from the local cache, so the network latency was now almost zero and the average response time was 30 times less.


Here are the new statistics after applying those changes. The number of calls to getTask and getCurrent state external WebServices from the OSB were dropped of the 99%, all the data were coming from the cache.



Here the Async BPEL service was facing the same latency calling the bundle services then the singe OSB services, but at least this time we were calling them with a list of users.

Here are some sequence diagram which explains now the sequence of the operations. The OSB Service now try to get the data from Coherence, if it is  not found it get the same from the OLD external services, and "subscribe" the users for update.

The SOA Business service was calling the external bundle services based on the "subscribed" users list.