Troubleshooting guide
231
15: Creating push applications
System.out.println(new String(someArray));
}
conn.disconnect();
} catch (IOException e) {
System.err.println(e);
}
}
private void readPapTemplate()
{
try {
String papFilename = “com/rim/samples/docs/httppush/pap_push.txt”;
InputStream ins = new BufferedInputStream(new FileInputStream(papFilename));
ByteArrayOutputStream bouts = new ByteArrayOutputStream();
copyStreams(ins, bouts);
this.requestTemplate = new String(bouts.toByteArray());
} catch (Exception exception) {
exception.printStackTrace();
}
}
private void setupNotifyThread()
{
if( !notificationThread.isAlive() )
{
notificationThread = new NotificationThread();
notificationThread.start();
}
}
private void papPush(String data)
{
String pushId=”pushID:”+random.nextInt();
setupNotifyThread();
readPapTemplate();
String errorCode = null;
try {
String mdsHost = “localhost”;
URL mdsUrl = new URL(“http”, mdsHost, MDS_PORT, “/pap”);
System.out.println(“ sending PAP request to “ + mdsUrl.toString() + “; pushId =
“ + pushId);
HttpURLConnection mdsConn = (HttpURLConnection)mdsUrl.openConnection();
String boundary = ““;
boundary = “asdlfkjiurwghasf”;
mdsConn.setRequestProperty(“Content-Type”, “multipart/related;
type=\”application/xml\”; boundary=” + boundary);
mdsConn.setRequestProperty(“X-Wap-Application-Id”, “/”);
mdsConn.setRequestProperty(“X-Rim-Push-Dest-Port”,”100”);