i got some code from here,thanks very muck.
but i can't send the push message.
who can help me..
-------------------------code----------------------------------------------------
private void process(HttpServletRequest request, HttpServletResponse
response) {
String target = null;
target = "192.168.1.66";
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("/IPv4=PLMN\"/>\r\n")
.append("<quality-of-service delivery-method=\"unconfirmed\"
network=\"GSM\" bearer=\"CSD\"/>")
.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=\"signal-high\" si-id=\"")
.append(vMessageID)
.append("\" href=\"")
.append("\"http://192.168.1.66:8080")
.append("\">")
.append("Download the Foodreg Application")
.append("</indication>\r\n")
.append("</si>\r\n")
.append("--multipart-boundary--\r\n");
System.out.println(buffer.toString());
//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;
}
String str_url="http://192.168.1.76:8080/cgi-bin/wap-push.cgi";
HttpClient client = new HttpClient();
// GetMethod get = new GetMethod(RequestUtil.PUSHSMS_URL);
PostMethod post = new PostMethod(str_url);
// prepare param
try {
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()));
System.out.println("lalalal"+post);
int status = client.executeMethod(post);
System.out.println("KannelSenderServlet.sendMessage() :
executing for "+", 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 ();
}
}
----------------------------------------------------
my bearer model is "CSD"... and use "pushkannel.conf"
the kannel WARNING info is "headers_acceptable:got unacceptable push
headers;
PPG:unparsable push headers,the request unaccaptable"
--
View this message in context:
http://www.nabble.com/about-using-java-programme-send-a-push-tf3752401.html#a10603917
Sent from the Kannel - User mailing list archive at Nabble.com.