Wednesday, November 15, 2006

Calling a BPEL process with UTL_DBWS PLSQL package

After struggeling with low level SOAP calls from PLSQL. I was able to use the UTL_DBWS package. This package gives you an abstract layer on top of the low-level SOAP calls.

On OTN the latest version of this package can be downloaded.
You have to execute the following steps:

  1. Download the CallOut WebService zip file.
  2. Execute note: 276554.1 (located at metalink.oracle.com)
  3. Load under 'sys' account the files dbwsa.jar then dbwsclient.jar (from the previous donwloaded zip files)
  • loadjava -u sys/change_on_install -r -v -f -genmissing –s –grant public dbwsa.jar
  • loadjava -u sys/change_on_install -r -v -f -genmissing –s –grant public dbwsclient.jar
After this step, apart of errors during the loading of the jar files, you must load the two sqlfiles; utl_dbws_body.sql, utl_dbws_decl.sql as owner sys.

Now you should able to call a web service from the database, here is an example of calling a BPEL process based on a document style (rpc is also working).




DECLARE
service_ utl_dbws.SERVICE;
call_ utl_dbws.CALL;
service_qname utl_dbws.QNAME;
port_qname utl_dbws.QNAME;
xoperation_qname utl_dbws.QNAME;
xstring_type_qname utl_dbws.QNAME;
response sys.XMLTYPE;
request sys.XMLTYPE;
begin
-- Set a proxy if needed
-- utl_dbws.set_http_proxy('www-proxy.oracle.com:80');
service_qname := utl_dbws.to_qname(null, 'HelloWorld');
service_ := utl_dbws.create_service(service_qname);
--
call_ := utl_dbws.create_call(service_);
--
utl_dbws.set_target_endpoint_address(call_,
'http://oracle.nl:7779/orabpel/default/HelloWorld/1.0');
utl_dbws.set_property(call_,'SOAPACTION_USE','TRUE');
utl_dbws.set_property(call_,'SOAPACTION_URI','process');
utl_dbws.set_property(call_,'OPERATION_STYLE','document');
--
-- Set the input
--
request := sys.XMLTYPE('
<HelloWorldProcessRequest
xmlns="http://oracle.nl/HelloWorld">
<input xmlns="http://oracle.nl/HelloWorld">
1234abcd
</input>
</helloworldprocessrequest>');
--
response := utl_dbws.invoke(call_, request);
--
dbms_output.put_line(response.getstringval());
end;
/




The UTL_DBWS package is described here.

8 comments:

BradW said...

Very nice solution!

Lawrence said...

I found your code example very useful, I didn't realise that the UTL_DBWS package could use a document style. I found the Oracle documentation almost useless.
But to get your code working I had to prefix every occurence of "utl_dbws" with "sys", and changed the "/helloworldprocessrequest" end tag to "/HelloWorldProcessRequest".
I found a problem with the UTL_DBWS package, it ignores attributes. Once I changed the attributes to elements in the SOAP request, it worked fine. Do you know of a way to support attributes with the UTL_DBWS package?
thanks

Anonymous said...

Once again Thanks for the inputs...

dschroff said...

This is really nice solution to call BPEL processes via dbms scheduler!

Excellent!

gary said...

It's very useful. I need this to integrate BPEL and Portal for approval process

Thanks a lot.

Nithya Swaminathan said...

I am trying to do this but I dont know where to run the loadjava. If I run the command loadjava I get a class not found error. Can you help me please.

Regards
Nithya

reshmi said...

It is really very understandable.But I cant find the 2nd point. "Execute note: 276554.1 (located at metalink.oracle.com)"..
I'm not able to login to metalink. Is there any other means by which i can get the execute note.??

anish said...

I have one question .
Can you please reply to it as soon as you can :
In the input that you were passing :

request := sys.XMLTYPE(' "HelloWorldProcessRequest xmlns="http://oracle.nl/HelloWorld" "input xmlns="http://oracle.nl/HelloWorld" 1234abcd /input /helloworldprocessrequest');


What does
xmlns="http://oracle.nl/HelloWorld"
This tag means , if i need to use this procedure to call my webservice , what i have to use in this place.

Please let me know as soon as you can .