1 Reply Latest reply on Feb 15, 2018 1:51 PM by L. Fernigrini

    Invoke a restful webservice from pl/sql

    Dennies John

      Dear all,

       

      I am new to xml or web service related pl/sql's

       

      I created a procedure as below

       

      create or replace procedure test_restfull_ws

      is

        req utl_http.req;

        res utl_http.resp;

        url varchar2(4000) := 'https://mohdnc-hms.moh.gov.kw/MOHWS-1/license';--

        name varchar2(4000);

        buffer varchar2(4000);

        content varchar2(4000) := '{"civilId":"'||'249080700202'||'", "type":"'||'p'||'"}';

      --civilId=249080700202 --type=p

      --'{"room":"'||p_room_id||'", "partySize":"'||p_party_Size||'"}';

      begin

      dbms_output.put_line(content);

      --D:\app\DBADMIN\product\11.2.0\dbhome_1\BIN\owm\wallets\DBADMIN

        UTL_HTTP.SET_WALLET ('file:D:\app\DBADMIN\product\11.2.0\dbhome_1\BIN\owm\wallets\DBADMIN', 'P22Jan2018_Wallet');

        req := utl_http.begin_request(url, 'GET',' HTTP/1.1');

        --utl_http.set_header(req, 'user-agent', 'mozilla/4.0');

        UTL_HTTP.SET_AUTHENTICATION(req, 'TEST', 'TEST333');

        utl_http.set_header(req, 'user-agent', 'license');

      utl_http.set_header(req, 'content-type', 'application/json');

        utl_http.set_header(req, 'Content-Length', length(content));

       

       

        utl_http.write_text(req, content);

        res := utl_http.get_response(req);

        -- process the response from the HTTP call

        begin

          loop

            utl_http.read_line(res, buffer);

            dbms_output.put_line(buffer);

          end loop;

          utl_http.end_response(res);

        exception

          when utl_http.end_of_body

          then

            utl_http.end_response(res);

        end;

      end test_restfull_ws;

       

       

      while running I am getting the error as

       

      PL/SQL procedure successfully completed.

       

       

      {"civilId":"249080700202", "type":"p"}

      <?xml version="1.0" encoding="UTF-8" standalone="yes"?><MOHWS-License><ErrorCode>Er:001</ErrorCode><ErrorMsg>Please provide valid Civil Id </ErrorMsg><ErrorMsgAr>Please provide valid Civil Id </ErrorMsgAr></MOHWS-License>

       

      Here it says that "Please provide valid Civil Id "

       

      The same parameters are working from Restlet cleint

       

      Can anyone help?

       

      Dennis