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 Name | WCSites Component used | Relative URI | HTTP Operation |
---|---|---|---|
getTicket | Authorization | cas/v1/tickets | GET |
getCourseIdByCode | Custom Asset Course | <SITE NAME>/types/<ASSET NAME>/search | GET |
getSessionIdByCode | Custom Asset Session | <SITE NAME>/types/<ASSET NAME>/search | GET |
getContentIdByName | Asset Generic | <SITE NAME>/types/<ASSET NAME>/search | GET |
getParentIdById | Asset Generic | <SITE NAME>/types/<ASSET NAME>/assets | GET |
createUpdateCourse | Asset Course | <SITE NAME>/types/<ASSET NAME>/assets | POST |
createUpdateCourseParent | Asset Generic | <SITE NAME>/types/<ASSET NAME>/assets | POST |
createUpdateSession | Custom Asset Session | <SITE NAME>/types/<ASSET NAME>/assets | POST |
isCourseSessionReady | Asset Course | <SITE NAME>/types/<ASSET NAME>/assets | GET |
isSessionDifferent | Custom Asset Session | <SITE NAME>/types/<ASSET NAME>/assets | GET |
deleteSession | Custom Asset Session | <SITE NAME>/types/<ASSET NAME>/assets | DELETE |
Below are some important point to highlight:
Then uncheck in the OSB Business Service the Chunked mode and redeploy it!
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.
- 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.