web services是目前比较流行的系统之间信息交互的一种方式,近段研究了下通过Oracle数据库utl_http包调用web services,以下为例子,基于Oracle 11gr2测试。
此两种方式基本相似,只是在写法、调用上有些出入。涉及的web services服务器端代码较简单,采用axis2(v1.5.4)实现,可直接利用axis官方提供的例子。
方式一:
procedure testWebServices is
soap_request varchar2(30000);
soap_respond varchar2(30000);
http_req utl_http.req;
http_resp utl_http.resp;
l_ws_url varchar2(1000);
l_ws_function varchar2(100);
l_ws_soapaction varchar2(100);
begin
--不传递参数
soap_request := '<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://ws.apache.org/axis2">
<soap:Body>
</soap:Body>
</soap:Envelope>';
l_ws_url := 'http://IP:port/axis2/services/Version/';
l_ws_soapaction := 'urn:getVersion';
--传递参数
soap_request := '<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd