Dear Ishtiaq Ahmed,
Sorry for my late response, I wrote a method to do the job:
Note:- you have to change: encoding=\"ISO-8859-6\" in the buffer code.
////////Start of method/////////
public String sendWapPush(String target,String downloadURL,String
downloadDetail) {
try {
StringBuffer buffer = new StringBuffer();
String vMessageID = "" + Math.random();
String message = "";
String host = "127.0.0.1";//kannel host
String port = "55012";//ppg port
String url = "http://" + host + ":" + port + "/wappush";
buffer.append("--asdlfkjiurwgasf\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//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.trim()).append("\"\r\n
deliver-before-timestamp=\"2010-06-18T06:13:00Z\"\r\n").append("deliver-after-timestamp=\"2008-06-17T06:45:00Z\"
").append("progress-notes-requested=\"true\">\r\n").append("<address
address-value=\"WAPPUSH=").append(target).append("/TYPE=PLMN\"/>\r\n").append("<quality-of-service
delivery-method=\"unconfirmed\"\r\nnetwork-required=\"true\"\r\n
network=\"GSM\"\r\nbearer-required=\"true\"\r\nbearer=\"SMS\"\r\n
priority=\"high\"/>").append("</push-message>\r\n").append("</pap>\r\n\r\n").append("--asdlfkjiurwgasf\r\n").append("Content-Type:
text/vnd.wap.si\r\n\r\n").append("<?xml version=\"1.0\"
encoding=\"ISO-8859-6\"?>\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(downloadURL).append("\">").append(downloadDetail).append("</indication>\r\n").append("</si>\r\n").append("--asdlfkjiurwgasf--\r\n\r\n");
message = buffer.toString();
target = url;
String content = message;
//public static String postData(String target, String content)
throws Exception {
//System.out.println(" About to post\nURL:" +
target + "content : " + content);
String responseD = "";
URL urlc = new URL(target);
URLConnection conn = urlc.openConnection();
// Set connection parameters.
conn.setDoInput(true);
conn.setDoOutput(true);
conn.setUseCaches(false);
conn.setRequestProperty("Content-Type", "multipart/related;
boundary=asdlfkjiurwgasf; type=application/xml");
//conn.setRequestProperty("Authorization", "Basic \"foo:bar\"");
conn.setRequestProperty("X-Kannel-SMSC", "smsc" + smsc);
conn.setRequestProperty("X-Kannel-From", smsc);
conn.setRequestProperty("Content-Length", "" +
content.length());
DataOutputStream outs = new
DataOutputStream(conn.getOutputStream());
// Write out the bytes of the content string to the stream.
outs.writeBytes(content);
outs.flush();
// Read response from the input stream.
BufferedReader in = new BufferedReader(new
InputStreamReader(conn.getInputStream()));
String temp;
while ((temp = in.readLine()) != null) {
responseD += temp + "\n";
}
temp = null;
outs.close();
in.close();
//System.out.println("Server response:\n" + responseD + "");
return responseD;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
////////////end of method////////
On Thu, Feb 26, 2009 at 3:58 PM, Ishtiaq Ahmed <[email protected]>wrote:
> Hi Fellows:
>
>
> Can someone help with the exact java code and minimum header set / PAP
> configuration / Content File... for sending the WAP Push through Kannel....
> The problem with my code is that The message is being sent in two
> segments....
>
>
> 2009-02-20 06:35:02 [23465] [2] DEBUG: WSP (UNIT): event arrived
> 2009-02-20 06:35:02 [23465] [2] DEBUG: WSP_UNIT: Connectionless push
> accepted
> 2009-02-20 06:35:02 [23465] [2] DEBUG: WSP: Mapping
> `application/vnd.wap.sic', WSP 1.2 to 0x002e.
> 2009-02-20 06:35:02 [23465] [2] ERROR: HTTP: Header does not contain a
> colon. BAD.
> 2009-02-20 06:35:02 [23465] [2] DEBUG: WSP: Mapping `X-Unknown', WSP 1.3 to
> 0xffffffff.
> 2009-02-20 06:35:02 [23465] [2] DEBUG: WSP: Mapping `Cache-Control', WSP
> 1.3 to 0x003d.
> 2009-02-20 06:35:02 [23465] [2] DEBUG: WSP: Mapping `Pragma', WSP 1.3 to
> 0x001f.
> 2009-02-20 06:35:02 [23465] [2] DEBUG: WSP: Mapping `User-Agent', WSP 1.3
> to 0x0029.
> 2009-02-20 06:35:02 [23465] [2] DEBUG: WSP: Mapping `Accept', WSP 1.3 to
> 0x0000.
> 2009-02-20 06:35:02 [23465] [2] DEBUG: WSP: Mapping `text/html', WSP 1.2 to
> 0x0002.
> 2009-02-20 06:35:02 [23465] [2] DEBUG: WSP: Mapping `image/gif', WSP 1.2 to
> 0x001d.
> 2009-02-20 06:35:02 [23465] [2] DEBUG: WSP: Mapping `image/jpeg', WSP 1.2
> to 0x001e.
> 2009-02-20 06:35:02 [23465] [2] DEBUG: WSP: Mapping `*', WSP 1.2 to
> 0xffffffff.
> 2009-02-20 06:35:02 [23465] [2] DEBUG: WSP: Mapping `q', WSP 1.2 to 0x0000.
> 2009-02-20 06:35:02 [23465] [2] DEBUG: WSP: Mapping `*/*', WSP 1.2 to
> 0x0000.
> 2009-02-20 06:35:02 [23465] [2] DEBUG: WSP: Mapping `q', WSP 1.2 to 0x0000.
> 2009-02-20 06:35:02 [23465] [2] DEBUG: WSP: Mapping `Content-Length', WSP
> 1.3 to 0x000d.
> 2009-02-20 06:35:02 [23465] [2] DEBUG: WSP: Mapping `Content-Type', WSP 1.3
> to 0x0011.
> 2009-02-20 06:35:02 [23465] [2] DEBUG: WSP: Mapping `Encoding-Version', WSP
> 1.3 to 0x0043.
> 2009-02-20 06:35:02 [23465] [2] DEBUG: WDP (wapbox): delivering 2 segments
> to bearerbox
>
>
>
> Regards,
>
> Ishtiaq Ahmed
>
>