Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

UTL_HTTP package

Alexis BFeb 4 2020 — edited Feb 6 2020

Hi All !

Hi have an old code in perl language that I must translate to a PL/SQL process

This process will create an xml file that we used later to update a currency rate, so there is calls to a webservice

As I never used webservices in PL/SQL, I made search on how to do this and found UTL_HTTP package

I checked the documentation but not founded exactly what I would

$soap = SOAP::Lite

-> uri('http://www.example.hu/webservices/')

-> on_action( sub { join '/','http://www.example.hu/webservices',$_[1] } )

-> proxy('http://www.example.hu/test.asmx');

/*

     For this part I think I would use

     UTL_HTTP.SET_PROXY('somthing', 'something');

     Is it correct ? In the perl process I used 1 proxy but the function need to parameter. Do you know wich one I need to complete ?

     Then will use

     req := UTL_HTTP.BEGIN_REQUEST('http://www.example.hu/webservices/ '); -- (req   UTL_HTTP.REQ;)

     Is it correct ?

     But not know how to define the perl on_action command ( on_action( sub { join '/','http://www.example.hu/webservices',$_[1] } ) )

     Any idea ?

*/

$method = SOAP::Data->name('GetExchangeRates')

->attr({xmlns => 'http://www.example.hu/webservices/'});

@params = ( SOAP::Data->name(startDate     => $date_now),

SOAP::Data->name(endDate       => $date_now),

SOAP::Data->name(currencyNames => 'EUR') );

/*

     This is the most complex piece for me

     I don't find what I need to use to define method GetExchangeRates and the attribute

     Any Idea ?

*/

$returned = $soap->call($method => @params)->result;

/*

     For this part I guess a piece that will look like

resp := UTL_HTTP.GET_RESPONSE(req); -- resp  UTL_HTTP.RESP;

  LOOP

    UTL_HTTP.READ_LINE(resp, value, TRUE);

    DBMS_OUTPUT.PUT_LINE(value); -- value VARCHAR2(1024);

  END LOOP;

  UTL_HTTP.END_RESPONSE(resp);

EXCEPTION

  WHEN UTL_HTTP.END_OF_BODY THEN

    UTL_HTTP.END_RESPONSE(resp);

                    Is it OK you think ?

*/

Best regards,

Comments
Post Details
Added on Feb 4 2020
13 comments
505 views