暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

Oracle 从web服务获取输出 (成功/失败) 状态

askTom 2017-10-31
378

问题描述

嗨,

您能否分享任何示例以将web服务输出 (即成功/失败) 状态获取到oracle PL/SQL过程中?

场景如下,

我们创建了一个存储过程,它将从这些输入参数中传递2个输入参数,将结果发送到web服务。使用创建的存储过程调用web服务,并根据其结果web服务生成成功/失败方面的输出。

是否可以再次将输出状态捕获到存储过程中?

请建议。

如果需要更多细节,请告诉我们。

谢谢。

专家解答

web服务通常会以某种输出格式 (例如html) 返回其状态。

您没有说您是如何调用web服务的,但是假设UTL_HTTP,那么您可以调用web服务,然后解析结果,例如

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



「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论