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

1 comment: