1 Reply Latest reply: Jan 1, 2013 7:37 AM by Osama_Mustafa RSS

    Sending SMS through Oracle

    460544
      I am using following code for send SMS through oracle:
      PROCEDURE sendSMS
      ( pRecipient IN VARCHAR2
      , pBody IN VARCHAR2
      )
      IS
      ESENDEX_USERNAME CONSTANT VARCHAR2(40) := '123';
      ESENDEX_PASSWORD CONSTANT VARCHAR2(40) := '123';
      ESENDEX_ACCOUNT CONSTANT VARCHAR2(40) := '123';
      --
      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://10.36.68.199:13131/cgi-bin/sendsms'
      , 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;



      and getting following error.
      ERROR at line 1:
      ORA-20001: Sending SMS failed with HTTP status: 400-Bad Request
      ORA-06512: at "SUPPLY.SENDSMS", line 74
      ORA-06512: at line 1

      what is the significance of this error?