我正在使用下面的代码在服务器上为Blackberry推送通知制作通知程序,但在下面显示错误。 任何人都可以帮助我在java中开发用于黑莓推送通知的服务器端应用程序。
Exception in thread "main" net.rim.pushsdk.commons.PushSDKException: Bad HTTP response returned: HttpResponse ( net.rim.pushsdk.commons.http.HttpResponse@10a93e5 statusCode = 404 content = https://cp****.pushapi.eval.blackberry.com contentType = null headerFields = {null=[HTTP/1.1 404 Not Found], Date=[Tue, 11 Jun 2013 12:38:52 GMT], Content-Length=[0], Server=[Apache-Coyote/1.1]} )
at net.rim.pushsdk.pap.PapServiceImpl.sendToPpg(PapServiceImpl.java:480)
at net.rim.pushsdk.pap.PapServiceImpl.pushToPpg(PapServiceImpl.java:446)
at net.rim.pushsdk.pap.PapServiceImpl.push(PapServiceImpl.java:174)
at BBM.main(BBM.java:82)
/ * ** * ** * ** * ** * *** /
/ * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * * /
import java.sql.Date;
import java.util.ArrayList;
import java.util.List;
import com.sun.org.apache.xalan.internal.xsltc.compiler.sym;
import net.rim.pushsdk.commons.IdGenerator;
import net.rim.pushsdk.commons.IdGeneratorImpl;
import net.rim.pushsdk.commons.PushSDKException;
import net.rim.pushsdk.commons.PushSDKProperties;
import net.rim.pushsdk.commons.PushSDKPropertiesImpl;
import net.rim.pushsdk.commons.UnauthorizedException;
import net.rim.pushsdk.commons.content.Content;
import net.rim.pushsdk.commons.content.TextContent;
import net.rim.pushsdk.commons.http.HttpClientImpl;
import net.rim.pushsdk.pap.PapBeanLocator;
import net.rim.pushsdk.pap.PapService;
import net.rim.pushsdk.pap.PapServiceImpl;
import net.rim.pushsdk.pap.StatusCode;
import net.rim.pushsdk.pap.control.PushMessageControl;
import net.rim.pushsdk.pap.unmarshal.BadMessageException;
import net.rim.pushsdk.pap.unmarshal.PushResponse;
import net.rim.pushsdk.pap.unmarshal.ResponseResult;
public class BBM {
private static String password = "********";
private static String targetURL = "https://cp****.pushapi.eval.blackberry.com";
private static final String APP_ID = "****-***********************************";
public static void main(String[] args) throws PushSDKException,
BadMessageException, UnauthorizedException {
org.apache.commons.codec.binary.Base64 b6;
// net.rim.pushsdk.acknowledgement.NotificationProcessorServiceImpl nsi;
IdGenerator idGenerator = new IdGeneratorImpl();
List<String> addresses = new ArrayList<String>();
String data = "this is a test message – 2";
System.out.println("Data is: " + data);
addresses.add("********");
PushMessageControl pushMessageControl = new PushMessageControl(true,
idGenerator, APP_ID, addresses);
Content content = new TextContent(data);
PapService papService = new PapServiceImpl();
PushSDKProperties properties = getBBProperties();
HttpClientImpl client = new HttpClientImpl();
client.setPushSDKProperties(properties);
papService.setHttpClient(client);
papService.setPushSDKProperties(properties);
PushResponse response = papService.push(APP_ID, password, APP_ID,
pushMessageControl, content);
ResponseResult result = response.getResult();
StatusCode statusCode = result.getCode();
String code = statusCode.getCode();
String description = result.getDescription();
System.out.println(""+statusCode+":"+description+":"+code);
System.out.println(response.getDescription());
private static PushSDKProperties getBBProperties() {
PushSDKProperties p = new PushSDKPropertiesImpl();
p.setPublicPpgAddress(targetURL);
p.setHttpIsPersistent(true);
p.setHttpConnectionTimeout(60000);
p.setHttpReadTimeout(120000);
return p;
}
}