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: 14
Registered: ‎12-09-2013
My Device: blackberry torch
My Carrier: vodafone
Accepted Solution

Java Push server problem

Hello,

I have developed a push server in java using code in http://supportforums.blackberry.com/t5/BlackBerry-Push-Development/Push-API-sample-code-needed/td-p/...

I used the URL as: https://cpxxxx.pushapi.eval.blackberry.com/mss/PD_pushRequest/

I am getting the below response:

 

200 | OK

 

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<title>Pushdata Service</title>
<body bgcolor="white" leftmargin="0" marginheight="0" marginwidth="0" topmargin="0">
<form enctype="application/x-www-form-urlencoded" method="get">

<!-- Header -->

<!-- static error header library -->

<br clear="none"/>

<!-- Errorcode -->

<!-- dynamic @[errorcode] token -->

<font color="#777777" size="1" style="verdana">Error </font>
<br clear="none"/>
<br clear="none"/>


<!-- Errorbody -->

<!-- dynamic @[errorbody] token -->

<font color="#777777" size="1" style="verdana">The content you have requested is not available</font>
<br clear="none"/>

<!-- Error message -->

<!-- dynamic @[errormsg] token -->

<br clear="none"/>
<font color="#777777" size="1" style="verdana">fetch command is not currently in service!</font>
<br clear="none"/>
<br clear="none"/>

<!-- Footer -->

<!-- static error footer library -->

<br clear="none"/>
</form>
</body>
</html>

 Could anyone please help me with this?

 

P.S.: I tried developing push server using PushSDK and got the below response:

net.rim.pushsdk.commons.PushSDKException: Unable to parse the response from this command because the content-type header field returned was not the expected: 'application/xml'. This may occur if the URL being accessed is wrong or the service at the URL is not available. Actual content-type returned was: text/html

I need help with atleast one of the above errors.

Contributor
Posts: 14
Registered: ‎12-09-2013
My Device: blackberry torch
My Carrier: vodafone

Re: Java Push server problem

Hi,

I tried, as an alternative solution, using the PUSH high level SDK and my java code is:

 

public static String pushMessage(){

IdGenerator idGenerator = new IdGeneratorImpl();
String address = "XXXXXXXX";

String message = "Hello World";

PushMessageControl pushMessageControl = new PushMessageControl(PPGType.PUBLIC_PUSH, idGenerator, "xxxx-AppID", address);

Content content = new TextContent(message, "UTF-8");

PapService papService = new PapServiceImpl();

PushSDKProperties properties = new PushSDKPropertiesImpl();
properties.setPublicPpgAddress("https://cpxxxx.pushapi.eval.blackberry.com/mss/PD_pushRequest/");
properties.setParserSpecialCharacters(BLACKBERRY_PARSER_SPECIAL_CHARACTERS);
properties.setHttpIsPersistent(false);
properties.setHttpConnectionTimeout(BLACKBERRY_CONNECTION_TIMEOUT);
properties.setDtdDeclarationPublic(BLACKBERRY_DTD_DECLARATION_PUBLIC);
properties.setHttpReadTimeout(BLACKBERRY_READ_TIMEOUT);

HttpClientImpl client = new HttpClientImpl();
client.setPushSDKProperties(properties);
papService.setHttpClient(client);
papService.setPushSDKProperties(properties);
try{
System.out.println("The content is " + content.toString());
System.out.println("The PAP msg is " + papService.toString());
PushResponse response = papService.push("xxxx-AppID", "PWD", "xxxx-AppID", pushMessageControl, content);
System.out.println("The response is " + response.toString());
return response.toString();
}catch(Exception e){
System.out.println("The Exception is " + e.toString());
return e.toString();
}
}

 The response was:

net.rim.pushsdk.commons.PushSDKException: Unable to parse the response from this command because the content-type header field returned was not the expected: 'application/xml'. This may occur if the URL being accessed is wrong or the service at the URL is not available. Actual content-type returned was: text/html

 

Could anybody please help here?

Retired
Posts: 2,559
Registered: ‎10-16-2009
My Device: BlackBerry Z10
My Carrier: Bell

Re: Java Push server problem

Hi,

 

Could you post the resulting XML message that is sent to the push server?

 

Please also message me the code being used (pasted above) but with the actual values used for the parameters (app ID, CPID, address etc).

 

Thanks,

Garett
@garettBeuk
--
Goodbye everybody!
Contributor
Posts: 14
Registered: ‎12-09-2013
My Device: blackberry torch
My Carrier: vodafone

Re: Java Push server problem

[ Edited ]

Hello Garett,

Please find below, my code with actual values:

 

package com.bb.sample;
import net.rim.pushsdk.commons.content.Content;
import net.rim.pushsdk.commons.IdGenerator;
import net.rim.pushsdk.commons.IdGeneratorImpl;
import net.rim.pushsdk.pap.control.PushMessageControl;
import net.rim.pushsdk.pap.control.PPGType;
import net.rim.pushsdk.commons.content.TextContent;
import net.rim.pushsdk.pap.PapService;
import net.rim.pushsdk.pap.PapServiceImpl;
import net.rim.pushsdk.commons.PushSDKProperties;
import net.rim.pushsdk.commons.PushSDKPropertiesImpl;
import net.rim.pushsdk.commons.http.HttpClientImpl;
import net.rim.pushsdk.pap.unmarshal.PushResponse;

public class SendPushMsg{
private static final int BLACKBERRY_READ_TIMEOUT = 120000;
private static final int BLACKBERRY_CONNECTION_TIMEOUT = 60000;
private static final char[] BLACKBERRY_PARSER_SPECIAL_CHARACTERS = new char[] {'&', '"', ':', '<'};
private static final String BLACKBERRY_DTD_DECLARATION_PUBLIC = "<!DOCTYPE pap PUBLIC \"-//WAPFORUM//DTD PAP 2.1//EN\" \"http://www.openmobilealliance.org/tech/DTD/pap_2.1.dtd\">";

public static String pushMessage(){

IdGenerator idGenerator = new IdGeneratorImpl();
String address = "devicePIN";

String message = "Hello World";

PushMessageControl pushMessageControl = new PushMessageControl(PPGType.PUBLIC_PUSH, idGenerator, "appID", address);

Content content = new TextContent(message, "UTF-8");

PapService papService = new PapServiceImpl();

PushSDKProperties properties = new PushSDKPropertiesImpl();
properties.setPublicPpgAddress("https://cpXXXX.pushapi.eval.blackberry.com/mss/PD_pushRequest/");
properties.setParserSpecialCharacters(BLACKBERRY_PARSER_SPECIAL_CHARACTERS);
properties.setHttpIsPersistent(false);
properties.setHttpConnectionTimeout(BLACKBERRY_CONNECTION_TIMEOUT);
properties.setDtdDeclarationPublic(BLACKBERRY_DTD_DECLARATION_PUBLIC);
properties.setHttpReadTimeout(BLACKBERRY_READ_TIMEOUT);

HttpClientImpl client = new HttpClientImpl();
client.setPushSDKProperties(properties);
papService.setHttpClient(client);
papService.setPushSDKProperties(properties);
try{
System.out.println("The content is " + content.toString());
System.out.println("The PAP msg is " + papService.toString());
PushResponse response = papService.push("appID", password, "appID", pushMessageControl, content);
System.out.println("The response is " + response.toString());
return response.toString();
}catch(Exception e){
System.out.println("The Exception is " + e.toString());
return e.toString();
}
}
}

 

 

 

Please find below the result:

 

The client is net.rim.pushsdk.commons.http.HttpClientImpl@e19b53


The Control is PushMessageControl ( net.rim.pushsdk.pap.control.PushMessageControl@19c7702 pushId = A3Us3lxd0Ke-1386739917015 deliverBeforeTimestamp = null sourceReference = 4213-e8766a5616iry28440o1rc66350aM918o23 ppgNotifyRequestedTo = 26DD3150 addresses = AddressList ( net.rim.pushsdk.pap.control.AddressList@69e03b1b addresses = [push_all] ) qualityOfService = QualityOfService ( net.rim.pushsdk.pap.control.QualityOfService@14942e1 deliveryMethod = confirmed bearer = null bearerRequired = false ) )

 

The content is TextContent ( Content ( net.rim.pushsdk.commons.content.TextContent@10e1e9d contentType = ContentType ( net.rim.pushsdk.commons.content.ContentType@1fc1695 contentType = text/plain parameters = {charset=UTF-8} ) headers = HttpHeaderList ( net.rim.pushsdk.commons.http.HttpHeaderList@12ecdbd headers = {} upperCaseHeaders = {} ) ) content = Hello World )


The PAP msg is net.rim.pushsdk.pap.PapServiceImpl@1c557cd


The Exception is net.rim.pushsdk.commons.PushSDKException: Unable to parse the response from this command because the content-type header field returned was not the expected: 'application/xml'. This may occur if the URL being accessed is wrong or the service at the URL is not available. Actual content-type returned was: text/html

 

I am not able to derive the resulting XML sent. I tried TCP/IP monitor over HTTP port in eclipse. It is not able to pick the transferred XML.

 

Please let me know incase any other detail is required.

 

*edited to remove sensitive account information

Contributor
Posts: 14
Registered: ‎12-09-2013
My Device: blackberry torch
My Carrier: vodafone

Re: Java Push server problem

[ Edited ]

Hello,

I figured out the way to construct the request XML message for the above java code using:
PapRequestMessage papRequestMessage = new PapRequestMessage(pushMessageControl, content);
System.out.println("The papRequestMessage is " + papRequestMessage.toString());

 


The result was:

The papRequestMessage is PapRequestMessage ( net.rim.pushsdk.pap.control.PapRequestMessage@1e6b85b control = PushMessageControl ( net.rim.pushsdk.pap.control.PushMessageControl@518444 pushId = ZI2B3FrRQ8E-1386743884359 deliverBeforeTimestamp = null sourceReference =  ppgNotifyRequestedTo = 26DD3150 addresses = AddressList ( net.rim.pushsdk.pap.control.AddressList@69e03b1b addresses = [push_all] ) qualityOfService = QualityOfService ( net.rim.pushsdk.pap.control.QualityOfService@1c2b27a deliveryMethod = confirmed bearer = null bearerRequired = false ) ) content = TextContent ( Content ( net.rim.pushsdk.commons.content.TextContent@1537f0e contentType = ContentType ( net.rim.pushsdk.commons.content.ContentType@ba95be contentType = text/plain parameters = {charset=UTF-8} ) headers = HttpHeaderList ( net.rim.pushsdk.commons.http.HttpHeaderList@1bcf16c headers = {Push-Message-ID=[ZI2B3FrRQ8E-1386743884359]} upperCaseHeaders = {PUSH-MESSAGE-ID=[ZI2B3FrRQ8E-1386743884359]} ) ) content = Hello World ) boundary = xZ91HRTk90nFIgpmOmRN )

Retired
Posts: 2,559
Registered: ‎10-16-2009
My Device: BlackBerry Z10
My Carrier: Bell

Re: Java Push server problem

Unfortunately that is not the XML, but it does include the information I was looking for Smiley Happy

 

Could you grab the full response from the server?

 

A few things that stood out to me in the information you provided:

1) You specify a PIN in your code, however the provided dump of the message shows no pin, rather a broadcast using "push_all", any ideas what's going on?

2) The output provided also shows the QualityOfService deliveryMethod set to "confirmed", but this should be set to "unconfirmed". This should not cause the failure you're seeing, but it may cause a failure due to being unsupported

Garett
@garettBeuk
--
Goodbye everybody!
Contributor
Posts: 14
Registered: ‎12-09-2013
My Device: blackberry torch
My Carrier: vodafone

Re: Java Push server problem

[ Edited ]

Hello Garett,

Thanks for your response.

I corrected my code.

Actually there was a mistake in using the constructor for PushMessageControl. I had specified the 'PIN' in the ppgNotifyRequestedTo field. 

I have modified the code appropriately to include the PIN in the address list of the constructor. 

The result is:

 

The papRequestMessage is PapRequestMessage ( net.rim.pushsdk.pap.control.PapRequestMessage@c2ee56 control = PushMessageControl ( net.rim.pushsdk.pap.control.PushMessageControl@1ad528b pushId = HmcdCa7jaAE-1386773915250 deliverBeforeTimestamp = null sourceReference =  ppgNotifyRequestedTo = null addresses = AddressList ( net.rim.pushsdk.pap.control.AddressList@ea6af95c addresses = [26DD3150] ) qualityOfService = QualityOfService ( net.rim.pushsdk.pap.control.QualityOfService@630d8 deliveryMethod = unconfirmed bearer = null bearerRequired = false ) ) content = TextContent ( Content ( net.rim.pushsdk.commons.content.TextContent@70d6c5 contentType = ContentType ( net.rim.pushsdk.commons.content.ContentType@243233 contentType = text/plain parameters = {charset=UTF-8} ) headers = HttpHeaderList ( net.rim.pushsdk.commons.http.HttpHeaderList@5be9bc headers = {Push-Message-ID=[HmcdCa7jaAE-1386773915250]} upperCaseHeaders = {PUSH-MESSAGE-ID=[HmcdCa7jaAE-1386773915250]} ) ) content = Hello World ) boundary = rHLugzBQQCA7dGoqXLnE )
The ppgtype is Public Push
The Client is net.rim.pushsdk.commons.http.HttpClientImpl@155f64e
The Control is PushMessageControl ( net.rim.pushsdk.pap.control.PushMessageControl@1ad528b pushId = HmcdCa7jaAE-1386773915250 deliverBeforeTimestamp = null sourceReference =  ppgNotifyRequestedTo = null addresses = AddressList ( net.rim.pushsdk.pap.control.AddressList@ea6af95c addresses = [26DD3150] ) qualityOfService = QualityOfService ( net.rim.pushsdk.pap.control.QualityOfService@630d8 deliveryMethod = unconfirmed bearer = null bearerRequired = false ) )
The content is TextContent ( Content ( net.rim.pushsdk.commons.content.TextContent@70d6c5 contentType = ContentType ( net.rim.pushsdk.commons.content.ContentType@243233 contentType = text/plain parameters = {charset=UTF-8} ) headers = HttpHeaderList ( net.rim.pushsdk.commons.http.HttpHeaderList@5be9bc headers = {Push-Message-ID=[HmcdCa7jaAE-1386773915250]} upperCaseHeaders = {PUSH-MESSAGE-ID=[HmcdCa7jaAE-1386773915250]} ) ) content = Hello World )
The PAP msg is net.rim.pushsdk.pap.PapServiceImpl@9da7ad
The Exception is net.rim.pushsdk.commons.PushSDKException: Unable to parse the response from this command because the content-type header field returned was not the expected: 'application/xml'. This may occur if the URL being accessed is wrong or the service at the URL is not available. Actual content-type returned was: text/html

 

Could you please help here?

Retired
Posts: 2,559
Registered: ‎10-16-2009
My Device: BlackBerry Z10
My Carrier: Bell

Re: Java Push server problem

Can you read the actual response received from the server? The output below is the interpreted exception as opposed to the actual reply.

Garett
@garettBeuk
--
Goodbye everybody!
Contributor
Posts: 14
Registered: ‎12-09-2013
My Device: blackberry torch
My Carrier: vodafone

Re: Java Push server problem

Should I use some external tool or any method/class to read the actual response?

How should I do it?

I am using eclipse J2EE on Windows XP.

Contributor
Posts: 14
Registered: ‎12-09-2013
My Device: blackberry torch
My Carrier: vodafone

Re: Java Push server problem

Could you please tell me how to read the actual response from the server?
Are there any logs written with the Push SDK?