Send SMS Procedure

221 views
Skip to first unread message

Manju Harish

unread,
Jul 24, 2013, 8:51:56 AM7/24/13
to oracle...@googlegroups.com
Hi everyone;
 
Am trying to send sms using oracle stored procedure .  Am getting an error message “ORA-20001: Sending SMS failed with HTTP status: 400-Bad Request”
 
The procedure code is as below :
 

CREATE OR REPLACE PROCEDURE Sendsms (precipient IN VARCHAR2, pbody IN VARCHAR2)IS

 

   esendex_username   CONSTANT VARCHAR2 (40)   := 'sun...@smartcall.ae   ';

   esendex_password   CONSTANT VARCHAR2 (40)   := 'sunt1';

   esendex_account    CONSTANT VARCHAR2 (40)   := 'smartcall.ae';

   vrequest                    utl_http.req;

   vposttext                   VARCHAR2 (500);

   vresponse                   utl_http.resp;

   vresponsetext               VARCHAR2 (2000);

   verrortext                  VARCHAR2 (200);

BEGIN

----------------------------------------------------------------------------

-- Build text for the post action.

-- For a field description, see

-- http://www.esendex.com/secure/messenger/formpost/SendSMS.aspx

----------------------------------------------------------------------------

   vposttext :=

         'EsendexPlainText=YES'

      || CHR (38)

      || 'EsendexUsername='

      || utl_url.ESCAPE (esendex_username, TRUE)

      || CHR (38)

      || 'EsendexPassword='

      || utl_url.ESCAPE (esendex_password, TRUE)

      || CHR (38)

      || 'EsendexAccount='

      || utl_url.ESCAPE (esendex_account, TRUE)

      || CHR (38)

      || 'EsendexRecipient='

      || utl_url.ESCAPE (precipient, TRUE)

      || CHR (38)

      || 'EsendexBody='

      || utl_url.ESCAPE (pbody, TRUE);

----------------------------------------------------------------------------

-- if you need to set a proxy, uncomment next line.

----------------------------------------------------------------------------

/* Utl_Http.set_proxy('proxy.it.my-company.com', 'my-company.com'); */

----------------------------------------------------------------------------

-- Send SMS through the Esendex SMS service.

----------------------------------------------------------------------------

   vrequest :=

      utl_http.begin_request

                            (url         => 'http://www.esendex.com/secure/messenger/formpost/SendSMS.aspx',

                             method      => 'POST'

                            );

   utl_http.set_header (r          => vrequest,

                        name       => 'Content-Type',

                        value      => 'application/x-www-form-urlencoded'

                       );

   utl_http.set_header (r => vrequest, name => 'Content-Length', value => LENGTH (vposttext));

   utl_http.write_text (r => vrequest, data => vposttext);

   vresponse := utl_http.get_response (vrequest);

 

   IF vresponse.status_code = '200'

   THEN

      utl_http.read_text (vresponse, vresponsetext);

 

      IF vresponsetext NOT LIKE 'Result=OK%'

      THEN

         verrortext := vresponsetext;

      END IF;

   ELSE

      verrortext := 'HTTP status: ' || vresponse.status_code || '-' || vresponse.reason_phrase;

   END IF;

 

   utl_http.end_response (vresponse);

 

   IF verrortext IS NOT NULL

   THEN

      RAISE_APPLICATION_ERROR (-20001, 'Sending SMS failed with ' || verrortext);

   END IF;

END Sendsms;

/

 

pLease help me.

 

ddf

unread,
Jul 24, 2013, 1:41:25 PM7/24/13
to oracle...@googlegroups.com
Without the username you're trying to send messages to it's difficult to assist you.
 
 
David Fitzjarrell 

Michael Moore

unread,
Jul 24, 2013, 1:50:44 PM7/24/13
to oracle-plsql
I don't really have an answer for your question, but have you considered sending email instead to an SMS gateway? http://en.wikipedia.org/wiki/List_of_SMS_gateways



--
--
You received this message because you are subscribed to the Google
Groups "Oracle PL/SQL" group.
To post to this group, send email to Oracle...@googlegroups.com
To unsubscribe from this group, send email to
Oracle-PLSQL...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/Oracle-PLSQL?hl=en
 
---
You received this message because you are subscribed to the Google Groups "Oracle PL/SQL" group.
To unsubscribe from this group and stop receiving emails from it, send an email to oracle-plsql...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages