0
我們如何從oracle調用一個asp.net webservice,我們可以有一個存儲過程來調用一個asp.net webservice嗎?如何從Oracle調用ASP.NET webservice?
我們如何從oracle調用一個asp.net webservice,我們可以有一個存儲過程來調用一個asp.net webservice嗎?如何從Oracle調用ASP.NET webservice?
這是一個簡單的存儲過程,它從oracle 調用一個簡單的ASP.NET附加Web服務,它使我們得到了由Oracle提供的兩個數字的附加結果。
CREATE OR REPLACE PROCEDURE sp_WsAdd
(
P_NUM1 number,
P_NUM2 number
)
AS
V_INVELOP_TEMP VARCHAR2(32767);
V_INVELOP VARCHAR2(32767);
V_REQUEST UTL_HTTP.REQ;
V_RESPONSE UTL_HTTP.RESP;
V_WSDL_URL VARCHAR2(2000):='Address of your Webservice';
V_XML XMLTYPE;
BEGIN
V_INVELOP:='<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<add xmlns="http://tempuri.org/">
<num1>'||P_NUM1||'</num1>
<num2>'||P_NUM2||'</num2>
</add>
</soap:Body>
</soap:Envelope>';
V_REQUEST:= UTL_HTTP.BEGIN_REQUEST(V_WSDL_URL, 'POST','HTTP/1.1');
UTL_HTTP.SET_BODY_CHARSET(V_REQUEST, 'UTF-8');
UTL_HTTP.SET_HEADER(V_REQUEST, 'Content-Type', 'text/xml');
UTL_HTTP.SET_HEADER(V_REQUEST, 'Content-Length', LENGTH(V_INVELOP));
UTL_HTTP.SET_HEADER(V_REQUEST, 'SOAPAction', 'http://tempuri.org/add');
UTL_HTTP.WRITE_TEXT(V_REQUEST, V_INVELOP);
V_RESPONSE := UTL_HTTP.GET_RESPONSE(V_REQUEST);
dbms_output.put_line('Response Received');
dbms_output.put_line('--------------------------');
dbms_output.put_line ('Status code: ' || V_RESPONSE.status_code);
dbms_output.put_line ('Reason phrase: ' || V_RESPONSE.reason_phrase);
UTL_HTTP.READ_TEXT(V_RESPONSE, V_INVELOP);
UTL_HTTP.END_RESPONSE(V_RESPONSE);
V_INVELOP := REPLACE(V_INVELOP,'xmlns="http://tempuri.org/"','');
V_XML:= XMLTYPE(V_INVELOP);
dbms_output.put_line('Value='||V_XML.extract('//addResult/text()').getStringVal());
commit;
END;
/
此存儲過程的Web服務是
[WebMethod]
public string add(int num1, int num2)
{
return (num1 + num2).ToString();
}