Explain:
Say we are subscribed to msegat.com service with the following credentials:
User Name : OMAR
Password : 123
User Sender : ThreeM ( you got it from your sms site)
Text we'll send : My_Test_Message
Phone we'll send message to : 966123456789
Here's how the code will run:
/*Start of SMS code*/
SET
serveroutput
ON
SET
Define
OFF
DECLARE
HTTP_REQ UTL_HTTP.REQ;
HTTP_RESP UTL_HTTP.RESP;
URL_TEXT VARCHAR2(32767);
URL VARCHAR2(2000);
SMS_MSG VARCHAR2(160) :=
'Congratulations! Your database has been configured propoerly for sending SMS through a 3rd party SMS Gateway'
;
BEGIN
DBMS_OUTPUT.ENABLE( 1000000);
--Based on your service provider, the following link format may differ from
--What we have specified below!
UTL_URL.
Escape
(SMS_MSG,
TRUE
);
--UTL_URL.Escape manages escape characters like SPACE between words in a message.
HTTP_REQ := UTL_HTTP.BEGIN_REQUEST(URL);
UTL_HTTP.SET_HEADER(HTTP_ REQ,
'User-Agent'
,
'Mozilla/4.0'
);
HTTP_RESP := UTL_HTTP.GET_RESPONSE(HTTP_ REQ);
-- Process Request
LOOP
BEGIN
URL_TEXT :=
null
;
UTL_HTTP.READ_ LINE(HTTP_RESP, URL_TEXT,
TRUE
);
DBMS_OUTPUT.PUT_ LINE(URL_TEXT);
EXCEPTION
WHEN
OTHERS
THEN
EXIT;
END
;
END
LOOP;
UTL_HTTP.END_RESPONSE( HTTP_RESP);
END
;
/*End of SMS code*/
If you got an error , you can remove :
SET
serveroutput
ON
SET
Define
OFF
"و فوق كل ذي علم عليم"
Salam Omar ... i tried your code ... does not work with me ... can you help pls ?
ReplyDeleteNeed some help in UTL_HTTP
need to send SMS from Oracle Database 11g
facing issues ...
I have 3rd party link. able to send SMS from browser and getting response OK ...
The moment i try from Database ... getting this error:
ORA-29273: HTTP request failed
ORA-06512: at "SYS.UTL_HTTP", line 1130
ORA-24247: network access denied by access control list (ACL)
ORA-06512: at line 21
ORA-29273
HTTP request failed
Cause: The UTL_HTTP package failed to execute the HTTP request.
Action: Use get_detailed_sqlerrm to check the detailed error message. Fix the error and retry the HTTP request.
Created ACL ... but still same
Best Regards
You must create a wallet with the root certificate of msegat.com
Delete