1

自过去几天以来,我一直在努力在设备上获取消息。最后我想寻求专家的帮助。

以下是我遵循的步骤。

  1. 我在核心 java 中创建了 Push 发起程序。注意:我收到响应代码:200 OK - 我假设此消息已到达 PPG 进行进一步处理 - 但未确认。

  2. 我已经为黑莓设备使用了示例推送启用应用程序 - 我可以注册并等待特定端口上的消息。但我没有收到任何消息:(

现在我很无助,我的问题是 1. 我是否在正确的轨道上 2. 有没有办法找出如何调试以及我的消息挂在哪里。

我正在等待一些积极的解决方案。提前致谢..

这是我为 J2SE 推送启动器的实际代码

StringBuffer dataToSend = new StringBuffer();
    dataToSend.append("--" + BOUNDARY);
    dataToSend.append(" ");
    dataToSend.append("Content-Type: application/xml; charset=UTF-8");
    dataToSend.append(" ");
    dataToSend.append("<?xml version=\"1.0\"?>");
    dataToSend
            .append("<!DOCTYPE pap PUBLIC \"-//WAPFORUM//DTD PAP 2.1//EN\" \"http://www.openmobilealliance.org/tech/DTD/pap_2.1.dtd\" [<?wap-pap-ver supported-versions=\"2.0\"?>]>");
    dataToSend.append("<pap>");
    String myPushId = ""+ new Random().nextInt();
    dataToSend.append("<push-message push-id=\"" + myPushId
            + "\" source-reference=\"" + applicationID + "\">");
    dataToSend.append("<address address-value=\"" + pin + "\"/>");
    dataToSend
            .append("<quality-of-service delivery-method=\"confirmed\"/>");
    dataToSend.append("</push-message>");
    dataToSend.append("</pap> ");
    dataToSend.append("--" + BOUNDARY);
    dataToSend.append(" Content-Encoding: binary ");
    dataToSend.append(" Content-Type: text/plain ");
    dataToSend.append(" ");
    dataToSend.append("X-Wap-Application-Id: " + applicationID);
    dataToSend.append(" X-Rim-Push-Type: browser-channel  X-Rim-Push-Title: Test X-Rim-Push-Unread-Icon: http://rim.com/icon_new.png ");
    dataToSend.append("X-Rim-Push-Read-Icon: http://rim.com/icon_viewed.png  ");
            dataToSend.append("X-Rim-Delete-URL: http://rim.com/ReceiveDelete ");
                    dataToSend.append("X-Rim-Transcode-Content: */* ");
                    dataToSend.append("Cache-Control: max-age=3600 ");
    dataToSend.append(msg);
    dataToSend.append("--" + BOUNDARY + "--");
    dataToSend.append(" ");
     printer(dataToSend.toString());
    // printer("-------------------------------------------------------------------");
    String authInfo = applicationID + ":" + userPW;

    String encoding = new sun.misc.BASE64Encoder().encode(authInfo
            .getBytes());
    // authInfo = Base64.encode(authInfo.getBytes());
    authInfo = "Basic " + encoding;
    printer(authInfo);
    URL url;
    HttpURLConnection connection = null;
    try {
        // Create connection
        url = new URL(targetURL);
        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.getBytes().toString());
        connection.setRequestProperty("Authorization", authInfo);

        connection.setRequestProperty("Accept",
                "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2");
        connection.setRequestProperty("Connection", "keep-alive");
        connection.setRequestProperty("Content-Length",
                "" + dataToSend.length());
        connection.setDoInput(true);
        connection.setDoOutput(true);

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

        printer("" + connection.getResponseCode());
        String response = connection.getResponseMessage();

        printer(response);
        // return response;
4

0 回答 0