Pergunta

I am creating a midlet that sends bulk sms web service having a url of this format

http://100.50.000.000/abcd_ws/?user=[USERNAME]&password=[PASSWORD]&from=[SENDER_ID]&to=[SINGLE_RECIPIENT]&message=[MESSAGE_TO_BE_SENT]

this is the method below that sends an SMS, as got from d J2me doc.

How do I encode the above URL into this method to allow for the message to be routed through this web service

public void send() {
        String mReceiver = null;
               // String mPort = null;
                mReceiver= getTextField2().getString();

                String address = "sms://" + mReceiver;

        MessageConnection conn = null; 
        try {
//            String addr = "sms://" + getTextField3().getString();
            conn = (MessageConnection) Connector.open(address);
            TextMessage msg = (TextMessage)conn.newMessage(MessageConnection.TEXT_MESSAGE);
            msg.setPayloadText(getComposeSMS().getString());
            conn.send(msg);
        } catch (Exception e) {

        }
        switchDisplayable(null, getConfirmation());

    }
Foi útil?

Solução

Sending SMS using the phone facilities and using web service are different things. You have to create HTTP connection and surf to URL of your web service using either GET or POST method (according to the documentation of the web service). Example of your URL contains parameters, so I guess you should use GET.

Take the following example http://www.java2s.com/Code/Java/J2ME/SampletodemonstrateHttpGETandPOSTfromMIDlet.htm

and modify it as you need.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top