Sunday, May 9, 2010

OSB: how to find which service/operation you are in

The $operation variable tells you the operation you are executing. But operation is not unique across all services, so to uniquely identify who you are you must add also the service information.

As reported here

<con:endpoint name="ProxyService$TestUpdateDB$PS$InsertInDbPS" xmlns:con="">
    <con:request xsi:type="http:HttpRequestMetaData" xmlns:http="" xmlns:xsi="">
      <tran:headers xsi:type="http:HttpRequestHeaders" xmlns:tran="">
        <http:Content-Type>text/xml; charset=utf-8</http:Content-Type>
      <tran:encoding xmlns:tran="">utf-8</tran:encoding>
    <con:response xsi:type="http:HttpResponseMetaData" xmlns:http="" xmlns:xsi="">
      <tran:headers xsi:type="http:HttpResponseHeaders" xmlns:tran="">
      <tran:response-code xmlns:tran="">0</tran:response-code>

there is a $inbound/con:endpoint/con:service variable, but this seems to be always empty :o( (there must a way to assign a value to it...). Theoretically con:service should specify providerName and operation, which sounds interesing, if only it was filled. Reading the docs here it becomes evident that this applies only to the $outbound variable while publishing... confusing indeed.

The alternative is using $inbound/ctx:transport/ctx:uri, that is the endpoint, which is unique. Better than losing your umbrella, as they say in Bologna.

We also learn that the XSDs MessageContext.xsd of the inbound and outbound elements are in a ORACLE_HOME/osb_10.3/lib/sb-schemas.jar , see here:

Interesting enough, the Reference.xsd file in the sb-schemas.jar contains a line which causes an error:

xs:import namespace=""

just remove it and the error goes away.

This script should return you the URI given the $inbound variable as input:

Pass $inbound as input, it should return you the Service URI

(:: pragma bea:local-element-parameter parameter="$inbound_endpoint1" type="ns0:messagecontext/ns0:inbound-endpoint" location="../../CommonResources/XSD/MessageReporting.xsd" ::)

declare namespace ns0 = "";
declare namespace xf = "";

declare function xf:getServiceFromInbound($inbound_endpoint1 as element())
as xs:string {
xs:string( data($inbound_endpoint1/ns0:transport/ns0:uri) )

declare variable $inbound_endpoint1 as element() external;


No comments: