Troubleshooting guide

232
BlackBerry Java Development Environment Development Guide
mdsConn.setRequestMethod(“POST”);
mdsConn.setAllowUserInteraction(false);
mdsConn.setDoInput(true);
mdsConn.setDoOutput(true);
String output = requestTemplate.replaceAll(“\\$\\(pushid\\)”, pushId);
output = output.replaceAll(“\\$\\(boundary\\)”, boundary);
output = output.replaceAll(“\\$\\(notifyURL\\)”, ““ + notifyURL);
output = output.replaceAll(“\\$\\(pin\\)”, ““ + _pinField.getText());
String deliveryMethod = “confirmed”;
output = output.replaceAll(“\\$\\(deliveryMethod\\)”, deliveryMethod);
output = output.replaceAll(“\\$\\(headers\\)”, “Content-Type: text/plain”);
output = output.replaceAll(“\\$\\(content\\)”, data);
output = output.replaceAll(“\r\n”, “EOL”);
output = output.replaceAll(“\n”, “EOL”);
output = output.replaceAll(“EOL”, “\r\n”);
System.out.println(output);
OutputStream outs = mdsConn.getOutputStream();
copyStreams(new ByteArrayInputStream(output.getBytes()), outs);
mdsConn.connect();
ByteArrayOutputStream response = new ByteArrayOutputStream();
copyStreams(mdsConn.getInputStream(), response);
int httpCode = mdsConn.getResponseCode();
if (httpCode != HttpURLConnection.HTTP_ACCEPTED) {
throw new Exception(“MDS returned HTTP status: “ + httpCode);
}
} catch (Exception exception) {
if (errorCode == null)
{
errorCode = exception.getClass().getName();
}
System.out.println(“ encountered error on submission: “ +
exception.toString());
}
}
public void copyStreams(InputStream ins, OutputStream outs) throws IOException
{
int maxRead = 1024;
byte [] buffer = new byte[1024];
int bytesRead;
for(;;)
{