Skip to Main Content
  • Questions
  • fetch output (success/failure) status from web service

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Ankit.

Asked: October 31, 2017 - 12:17 pm UTC

Last updated: November 03, 2017 - 6:12 am UTC

Version: 12.1.0

Viewed 1000+ times

You Asked

Hi,

Could you please share any example to fetch web service output (i.e. success/failure) status into oracle PL/SQL procedure?

The scenario is as below,

we have created a stored procedure which will pass 2 input parameters from those input parameters sending the results to web service. The web service is getting called with created stored procedure and based on their results web service generating output in terms of success/failure.

Is it possible to capture output status into stored procedure again?

Please suggest.

Let us know if required more details.

Thanks.

and Connor said...

A web service typically will return its status wrapped in some output format (eg html ).

You didn't say how you were calling the web service, but assuming UTL_HTTP, then you can call the webservice and then parse the result, eg

SQL> create table t ( c clob );

Table created.

SQL> declare
  2    l_req   utl_http.req;
  3    l_resp  utl_http.resp;
  4    l_content           clob;
  5    l_buffer           varchar2(1000);
  6  begin
  7    insert into t values ( empty_clob()) returning c into l_content;
  8
  9    l_req  := utl_http.begin_request('http://localhost:8080/ords/scott/emp/');
 10    l_resp := utl_http.get_response(l_req);
 11
 12    begin
 13      loop
 14        utl_http.read_text(l_resp, l_buffer, 999);
 15        dbms_lob.writeappend (l_content, length(l_buffer), l_buffer);
 16      end loop;
 17    exception
 18      when utl_http.end_of_body then
 19        utl_http.end_response(l_resp);
 20    end;
 21
 22     commit;
 23  end;
 24  /

PL/SQL procedure successfully completed.

SQL>
SQL> set long 300
SQL> select * from t;
{"items":[{"empno":7369,"ename":"SMITH","job":"CLERK","mgr":7902,"hiredate":"198
0-12-16T16:00:00Z","sal":800,"comm":null,"deptno":20,"links":[{"rel":"self","hre
f":"http://localhost:8080/ords/scott/emp/7369"}]},{"empno":7499,"ename":"ALLEN",
"job":"SALESMAN","mgr":7698,"hiredate":"1981-02-19T16:00:00Z



Rating

  (1 rating)

Is this answer out of date? If it is, please let us know via a Comment

Comments

A reader, November 22, 2017 - 9:47 am UTC

thanks a lot...

More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library