I am attaching my code here : Please spend some time for me thansk a lot..
-------------------------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: multipart/related; boundary=asdlfkjiurwghasf \r\n\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("/TYPE=PLMN\"/>\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:8080/epclrrt.jar")
.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;
}
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)
});
Part[] parts = { new StringPart("Content-type:","application.vnd.wap.mms-message")};
post.setRequestEntity(new MultipartRequestEntity(parts, post.getParams()));
int status = client.executeMethod(post);
System.out.println("KannelSenderServlet.sendMessage() : executing for " + RequestUtil.PUSHSMS_URL + ", status = " + status);
if ( HttpStatus.SC_OK != status) {
// request is successful
System.out.println("KannelSenderServlet.sendMessage() : WAP PUSH Failed : " + post.getStatusLine());
}
} catch (Exception e) {
System.out.println("KannelSenderServlet.sendMessage() : Unable to execute request: " + e.getMessage());
} finally {
post.releaseConnection ();
}
}
-----------------------------------------------CODE--------------------------------------------------------
On 8/18/06,
Deon van der Merwe <[EMAIL PROTECTED]> wrote:
Hi Kavuri,
Are you setting this header?
Content-Type: multipart/related; boundary=multipart-boundary;
type=application/xml
On 8/18/06, Kavuri Prasad <[EMAIL PROTECTED] > wrote:
>
> 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".
>
--
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
