×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Jan 2010
    Posts
    6

    Problem: posting URL from server.

    I'm trying to send sms using a url from server to mobile. i'm specifying mobile number and sms text message in the url itself and i'm using the following code.

    Looking forward for your support and positive response.


    import java.net.HttpURLConnection;
    import com.mcommerce.util.Logger;
    import java.io.DataOutputStream;
    import java.net.URL;





    /**
    *
    * @author admin
    */
    public class SmsHandler {



    public void sendMessage()
    {
    sendConformationMessage();
    }


    private void sendConformationMessage()
    {



    try

    {
    //HttpURLConnection http = null;

    URL url = new URL("www.myhost.com/sendsms");
    String data = "?Username=ANOther.12345&PIN=9292&SendTo=9986525405&Message=Testtest ";

    HttpURLConnection connection=(HttpURLConnection) url.openConnection();
    // RequestResponceHandler.sendMessage(connection.getOutputStream(),url);
    connection.setRequestMethod("POST");
    connection.setRequestProperty("Content-Type", "" + Integer.toString(data.getBytes().length));

    connection.setDoOutput(true);

    //connection.s
    DataOutputStream wr = new DataOutputStream (connection.getOutputStream ());
    System.out.println("Resultant " + connection.getResponseCode() ) ;
    if(connection.getResponseCode() == HttpURLConnection.HTTP_OK){
    wr.write(data.getBytes());
    System.out.println("SMS data"+data);
    wr.flush();
    wr.close();

    }


    //wr.writeBytes ("url");
    //wr.flush ();
    //wr.close ();
    connection.disconnect();
    }
    catch (Exception ex)
    {
    //Logger.getLogger().printException(ex);
    ex.printStackTrace();
    }
    }

    /* public static void main(String[] args){

    try{

    SmsHandler handler = new SmsHandler();
    handler.sendConformationMessage();

    }catch(Exception ex){
    ex.printStackTrace();
    }
    }*/



    }



    PLease help me to sort out this problem.....



    Thanks and Regards
    ANup....

  2. #2
    Super Contributor
    Join Date
    Mar 2003
    Location
    Finland
    Posts
    9,553

    Re: Problem: posting URL from server.

    Ask for help from whomever has developed "www.myhost.com/sendsms" (i.e., who created this "sendsms" application and what is it doing to send the SMS; presumably it either connects directly to a cellular modem to send the SMS, or it connects to some network operator's SMS-C servers directly or indirectly), short message service center).

Similar Threads

  1. Posting More log message in Dm server
    By questthirst in forum OMA DM/DS/CP
    Replies: 0
    Last Post: 2010-07-06, 13:26
  2. Not able to retrieve image while posting data on server
    By manmeet_narang in forum Mobile Java Networking & Messaging & Security
    Replies: 1
    Last Post: 2010-01-06, 05:01
  3. Posting data to a server
    By ms_sarwar1 in forum Symbian
    Replies: 38
    Last Post: 2009-10-13, 08:02
  4. Problem with posting data to the server.
    By chetubc in forum Mobile Java General
    Replies: 4
    Last Post: 2008-09-19, 08:23
  5. posting contacts to the server
    By sangeethavijaysekar in forum Symbian
    Replies: 6
    Last Post: 2007-04-10, 08:33

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×