Hi Deon,

Thanks for your reply.
I followed exactly as you said. But I am getting an error at Kannel side :
Can you please guide me about setting the content type as header. I am always getting following error : "No MIME content received, the request unacceptable".
 

---------PROBLEM Description -------------------------------
PPG: ip_allowed_by_ppg: ip found from allowed list
2006-08-15 16:02:16 [15608] [14] INFO: PPG: Accept request </cgi-bin/wappush.cgi> from < 192.168.0.102>
2006-08-15 16:02:16 [15608] [14] WARNING: PPG: No MIME content received, the request unacceptable
2006-08-15 16:02:16 [15608] [14] DEBUG: PPG: send_bad_message_response: telling pi

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

In my Java application Iam using pache commons HttpClient to process the USL. I am using Post Method !!!
my code: ------------------------- Java Code ----------------------------------------
private void process(HttpServletRequest request, HttpServletResponse response) {
        String target = null;
        target = "0060133186859";
        StringBuffer buffer = new StringBuffer();
        String vMessageID="[EMAIL PROTECTED]";
        // appending message
        buffer.append("--multipart-boundary\r\n")

        .append("Content-type: application/xml\r\n\r\n")
        .append("<?xml version=\"1.0\"?>\r\n")
        .append("<!DOCTYPE pap PUBLIC \"-//WAPFORUM//DTD PAP 1.0//EN\"\r\n")
        .append("\"http://www.wapforum.org/DTD/pap_1.0.dtd\ " >\r\n")
        .append("<pap>\r\n")
        .append("<push-message push-id=\"")
        .append(vMessageID)
        .append("\">\r\n")
        .append("<address address-value=\"WAPPUSH=")
        .append(target)

        .append("/[EMAIL PROTECTED]"/>\r\n")
        .append("<quality-of-service delivery-method=\"unconfirmed\" network=\"GSM\" bearer=\"SMS\"/>")
        .append("</push-message>\r\n")
        .append("</pap>\r\n\r\n")
        .append("--multipart-boundary\r\n")
        .append("Content-type: text/vnd.wap.si\r\n\r\n")
        .append("<?xml version=\"1.0\"?>\r\n")
        .append("<!DOCTYPE si PUBLIC \"-//WAPFORUM//DTD SI 1.0//EN\"\r\n")
        .append("\" http://www.wapforum.org/DTD/si.dtd\">\r\n")
        .append("<si>\r\n")
        .append("<indication action="" si-id=\"")
        .append(vMessageID)
        .append("\" href="">
        .append("http://foodreg.dnsalias.net")
        .append("\">")
        .append("Download the Foodreg Application")

        .append("</indication>\r\n")
        .append("</si>\r\n")
        .append("--multipart-boundary--\r\n");
        //Process the received xml file and prepare sms
        sendMessage(target, buffer.toString());
       
    }

    private void sendMessage(String target, String message) {
        if (null == target) {
            System.out.println("KannelSenderServlet.sendMessage () : Unable to send message! target number is null!");
            return;
        }
        Header header = new Header();
       
        HttpClient client = RequestUtil.getClient();
//        GetMethod get = new GetMethod( RequestUtil.PUSHSMS_URL);
        PostMethod post = new PostMethod(RequestUtil.PUSHSMS_URL);
        // prepare param
        try {
//            get.setQueryString(new NameValuePair[] {
//                    new NameValuePair("username", "foo"),
//                    new NameValuePair("password", "bar"),
//                    new NameValuePair("to", target),
//                    new NameValuePair("text", message)
//            });
            post.setQueryString(new NameValuePair[] {
                    new NameValuePair("username", "foo"),
                    new NameValuePair("password", "bar"),
                    new NameValuePair("to", target),
                    new NameValuePair("text", message)
            });
            int status = client.executeMethod(post);
            System.out.println("KannelSenderServlet.sendMessage() : executing for " + RequestUtil.SENDSMS_URL + ", status = " + status);
            if (HttpStatus.SC_OK == status) {
                // request is successful
                System.out.println("KannelSenderServlet.sendMessage () : Sending SMS to target recipient successful...");
            }
        } catch (Exception e) {
            System.out.println(" KannelSenderServlet.sendMessage() : Unable to execute request: " + e.getMessage());
        } finally {
            post.releaseConnection();
        }               
    }
}


-------------------------END ----------------------------------------

Thanks alot for your time ....
 


On 8/15/06, Deon van der Merwe <[EMAIL PROTECTED]> wrote:
Hi Kavuri,

On 8/15/06, Kavuri Prasad <[EMAIL PROTECTED] > wrote:
> I have to push an URL to the mobile. For this I planned to use PUSH Proxy
> Gateway. I have configured PPG under kannel. (Kannel's SMSC and WAP services
> are working fine).
> But I do not know how to initiate this Kannel's PPG service from my Java
> coding. Can some one help me?
>

Here is more or less how we use it:
- I build the message up:
   java.lang.StringBuffer vBody = new java.lang.StringBuffer();
   vBody.append("--multipart-boundary\r\n")
        .append("Content-type: application/xml\r\n\r\n")
        .append("<?xml version=\"1.0\"?>\r\n")
        .append("<!DOCTYPE pap PUBLIC \"-//WAPFORUM//DTD PAP 1.0//EN\"\r\n")
        .append("\"http://www.wapforum.org/DTD/pap_1.0.dtd\" >\r\n")
        .append("<pap>\r\n")
        .append("<push-message push-id=\"")
        .append(vMessageID)
        .append("\">\r\n")
        .append("<address address-value=\"WAPPUSH=")
        .append(vMSISDN)
        .append("/[EMAIL PROTECTED]"/>\r\n")
        .append("<quality-of-service delivery-method=\"unconfirmed\"
network=\"GSM\" bearer=\"SMS\"/>")
        .append("</push-message>\r\n")
        .append("</pap>\r\n\r\n")
        .append("--multipart-boundary\r\n")
        .append("Content-type: text/vnd.wap.si\r\n\r\n")
        .append("<?xml version=\"1.0\"?>\r\n")
        .append("<!DOCTYPE si PUBLIC \"-//WAPFORUM//DTD SI 1.0//EN\"\r\n")
        .append("\" http://www.wapforum.org/DTD/si.dtd\">\r\n")
        .append("<si>\r\n")
        .append("<indication action="" si-id=\"")
        .append(vMessageID)
        .append("\" href="">        .append(vURL)
        .append("\">")
        .append(vMessage)
        .append("</indication>\r\n")
        .append("</si>\r\n")
        .append("--multipart-boundary--\r\n");
- POST the message to kannel using a HTTP connection and setting the
following header:
     Content-Type = "multipart/related; boundary=multipart-boundary;
type=application/xml"




--
Thanks,
Prasad Kavuri
Software Consultant
Mobile Lifestyle Sdn. Bhd.
Unit F10 Block 3 (2320)
Century Square
63000 Cyberjaya
Malaysia.
Tel: +60 3 8318 6691
Fax:+60 3 8318 7760
HP: +60 12 927 4711

Reply via email to