-- Example about how to call modelSetDocAction from oracle pl/sql function
-- Following sample from http://technology.amis.nl/blog/358/consuming-web-services-from-plsql-part-ii-a-pure-plsql-solution-using-utl_http-oracle-9i-or-10g
CREATE OR REPLACE FUNCTION ws_modelsetdocaction (
p_table IN ad_table.tablename%TYPE,
p_recordid IN m_inout.m_inout_id%TYPE,
p_newdocstatus IN m_inout.docstatus%TYPE,
p_user IN ad_user.NAME%TYPE,
p_password IN ad_user.PASSWORD%TYPE,
p_language IN ad_language.ad_language%TYPE,
p_client_id IN ad_client.ad_client_id%TYPE,
p_role_id IN ad_role.ad_role_id%TYPE,
p_org_id IN ad_org.ad_org_id%TYPE,
p_warehouse_id IN m_warehouse.m_warehouse_id%TYPE
)
RETURN VARCHAR2
AS
server VARCHAR2 (100) := '127.0.0.1:8081';
soap_request VARCHAR2 (30000);
soap_respond VARCHAR2 (30000);
http_req UTL_HTTP.req;
http_resp UTL_HTTP.resp;
resp XMLTYPE;
BEGIN
soap_request :=
'
' || p_table || '
' || p_recordid || '
' || p_newdocstatus || '
' || p_user || '
' || p_password || '
' || p_language || '
' || p_client_id || '
' || p_role_id || '
' || p_org_id || '
' || p_warehouse_id || '
';
UTL_HTTP.set_transfer_timeout (5);
http_req :=
UTL_HTTP.begin_request ( 'http://' || server || '/ADInterface/services/ADService',
'POST',
'HTTP/1.1'
);
UTL_HTTP.set_header (http_req, 'Content-Type', 'text/xml');
UTL_HTTP.set_header (http_req, 'Content-Length', LENGTH (soap_request));
UTL_HTTP.write_text (http_req, soap_request);
http_resp := UTL_HTTP.get_response (http_req);
UTL_HTTP.read_text (http_resp, soap_respond);
UTL_HTTP.end_response (http_resp);
RETURN soap_respond;
/*
-- Create an XMLType variable containing the Response XML
resp := XMLTYPE.createxml (soap_respond);
-- extract from the XMLType Resp the child-nodes of the element
resp :=
resp.EXTRACT ('/soap:Envelope/soap:Body/child::node()',
'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"'
);
-- extract from the XMLType Resp the text() nodes from the n:getRateResponse/Result element
resp :=
resp.EXTRACT ('n:getRateResponse/Result/text()',
'xmlns:n="urn:xmethods-CurrencyExchange"'
);
RETURN resp.getclobval ();
*/
END;
/
-- Now you can make a call to the function with this example:
-- example to COmplete M_InOut with M_Inout_ID=1000002
/*
select ws_modelsetdocaction (
'M_InOut',
1000002,
'CO',
'SuperUser',
'System',
'es_CO',
11,
102,
11,
103)
from dual;
*/