Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

BlackBerry Push Development

Reply
Contributor
Posts: 37
Registered: ‎09-15-2010
My Device: 9800
My Carrier: Movistar

fail to start sample push service

when I run https: / / localhost: 8443/debug-portal / and the HTTP server responds 404 and looks at the log and says "GET / debug-portal / HTTP/1.1" 404 960, which may be failing to start running application "Thanks in advance

Highlighted
Regular Contributor
Posts: 55
Registered: ‎02-17-2010
My Device: BB8100
My Carrier: Airtel

Re: fail to start sample push service

Your problem is not clear to me...

if you are trying to access the specified url from your browser then check whether the tomcat(installed with push sdk) is running or not.

if you are trying to access this url from your blackberry device then use an external url instead of localhost. you can also use local ip of machine if connected to BES in same network.

 

Pulkit

 

Contributor
Posts: 37
Registered: ‎09-15-2010
My Device: 9800
My Carrier: Movistar

Re: fail to start sample push service

apologies for not being clear in the exposición the problem,
Tomcat is running with push with sdk installed, the problem
is when I put the url: https: / / localhost: 8443/debug-portal,
Responds and the HTTP server 404 and looks at the log and says "GET / debug-portal / HTTP/1.1" 404 960, 
which may be failing to start running application the sample debug-portal Thank you for your answer.

New Contributor
Posts: 4
Registered: ‎09-17-2010
My Device: Not Specified

Re: fail to start sample push service

[ Edited ]

forget the apps ... just use a servlet with the code below to do the push from the server side and download the sample client app, configure the client app with the information you receive from blackberry ...

 

 

 

 

 public ModelAndView postData(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) {

  String m_blackberryPushHost = "https://pushapi.eval.blackberry.com/mss/PD_pushRequest";
  // the port value obtained from the Blackberry after registration
  String m_blackberryPushPort = "xxxxx";

  //csv value of the device pin ex, ABCDEFG1,ABCDEFG2
  String pin = httpServletRequest.getParameter("pins");
  String m_blackberryApplicationId = "xxx-xxxxxxxxxxxxxxxxx";
  String m_blackberryApplicationPasswd = "xxxxxxxxx";
  String message = "It's " + new Date();
  
  int deliverBefore = 28800; // set to maximum allowed of 8 hours

  Calendar c = Calendar.getInstance();

  c.add(Calendar.SECOND, deliverBefore);
  SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
  String ts = sdf.format(c.getTime());
  

  String BOUNDARY = "mPsbVQo0a68eIL3OAxnm";
  StringBuffer sb = new StringBuffer();
  sb.append("--" + BOUNDARY);
  sb.append("\r\n");
  sb.append("Content-Type: application/xml; charset=UTF-8");
  sb.append("\r\n");
  sb.append("<?xml version=\"1.0\"?>");
  sb.append("\r\n");
  sb.append("<!DOCTYPE pap PUBLIC \"-//WAPFORUM//DTD PAP 2.1//EN\" \"http://www.openmobilealliance.org/tech/DTD/pap_2.1.dtd\">");
  sb.append("\r\n");
  sb.append("<pap>");
  sb.append("\r\n");
  String myPushId = ""+(new Date()).getTime();
  sb.append("<push-message push-id=\"" + myPushId + "\" source-reference=\"" + m_blackberryApplicationId +"\"  deliver-before-timestamp=\"" + ts + "\">\r\n");
  
  Scanner scanner = new Scanner(pin).useDelimiter(",");
  while (scanner.hasNext()) {
   sb.append("<address address-value=\"" + scanner.next() + "\"/>\n");
  }
  

  sb.append("<quality-of-service delivery-method=\"unconfirmed\"/>\r\n");
  sb.append("</push-message>\r\n");
  sb.append("</pap>\r\n");
  sb.append("--" + BOUNDARY + "\r\n");
  sb.append("Content-Type: text/plain" + "\r\n\r\n");
  sb.append(message + "\r\n");
  sb.append("--" + BOUNDARY + "\r\n");

  
  System.out.println(sb.toString());
  
  String authInfo = m_blackberryApplicationId + ":" + m_blackberryApplicationPasswd;
  authInfo = new String(Base64.encode(authInfo.getBytes()));
  authInfo = "Basic " + authInfo;
  System.out.println(authInfo);
  URL url;
  HttpURLConnection connection = null;
  try {
   url = new URL("https://pushapi.eval.blackberry.com/mss/PD_pushRequest");
   System.out.println("complete push url: " + url);
   connection = (HttpURLConnection) url.openConnection();
   connection.setRequestMethod("POST");
   connection.setRequestProperty("Content-Type", "multipart/related; boundary=" + BOUNDARY + "; type=application/xml");
   connection.setRequestProperty("User-Agent", "BlackBerry Push Service SDK/1.0");
   connection.setRequestProperty("Authorization", authInfo);
   connection.setRequestProperty("X-Rim-Push-Dest-Port", "" + m_blackberryPushPort);
   connection.setRequestProperty("Accept", "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2");
   connection.setRequestProperty("Connection", "keep-alive");
   connection.setRequestProperty("Content-Length", "" + sb.length());
   connection.setDoInput(true);
   connection.setDoOutput(true);

   // Send request
   DataOutputStream wr = new DataOutputStream(connection.getOutputStream());
   wr.writeBytes(sb.toString());
   wr.flush();
   wr.close();

   DataInputStream ir = new DataInputStream(connection.getInputStream());

   ByteArrayOutputStream response = new ByteArrayOutputStream();
   copyStreams(ir, response);

   System.out.println("Response code: " + connection.getResponseCode());
   System.out.println("respones was: " + response.toString());

   return null;

  } catch (Exception e) {
   e.printStackTrace();
  } finally {
   if (connection != null) {
    connection.disconnect();
   }
  }
  return null;
 }

 

 private void copyStreams(InputStream ins, OutputStream outs) throws IOException {

  byte[] buffer = new byte[1024];
  int bytesRead;

  for (;Smiley Wink {
   bytesRead = ins.read(buffer);
   if (bytesRead <= 0) {
    break;
   }
   outs.write(buffer, 0, bytesRead);
  }
 }