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
Regular Contributor
martinwang
Posts: 84
Registered: ‎12-02-2009
My Device: Not Specified

Re: Try to query Supplying a status to request subscribed addresses from Blackberry push sever get malform reasponse

It works, Thanks very much, You are really great!
Please use plain text.
Regular Contributor
martinwang
Posts: 84
Registered: ‎12-02-2009
My Device: Not Specified

Re: Try to query Supplying a status to request subscribed addresses from Blackberry push sever get malform reasponse

Hi marco_dicesare,

I try suspend with following function. I got error. Could hel me check code? thanks.

My suspend function:

public void suspend(Transaction tx, boolean isEnterprise ) throws IOException {
if( isEnterprise ) {
// if BES communication is involved then we don't unregister from BPS
return;
}
String suspendUrl = formSuspendRequest( PushConfig.getBpsUrl(), PushConfig.getAppId(), null );
String response = PushUtils.request( suspendUrl, tx );
suspendUrl = formSuspendRequest( PushConfig.getBpsUrl(), PushConfig.getAppId(), response );
response = PushUtils.request( suspendUrl, tx );
if( DEREGISTER_SUCCESSFUL.equals( response ) || ALREADY_UNSUSCRIBED_BY_USER.equals( response )
|| ALREADY_UNSUSCRIBED_BY_PROVIDER.equals( response ) ) {
// successfully unregistered
} else {
// rejected by BPS
Logger.warn( "BPS rejected suspend" );
throw new IOException( "BPS server rejected suspend. Details: response code - " + response );
}
}


error log:

Executing command 'suspend' ...Opening URL: http://pushapi.na.blackberry.com/mss/PD_cpSub?cpAction=suspend&pin=XXXXXXXX;deviceside=false;Connect... response: <?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...Opening URL: http://pushapi.na.blackberry.com/mss/PD_cpSub?cpAction=suspend&pin=XXXXXXXX&<?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....HTTP response: <?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...Command 'suspend' failed with error: java.io.IOException: BPS server rejected suspend. Details: response code - <?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/D...
Please use plain text.
BlackBerry Development Advisor (Retired)
marco_dicesare
Posts: 76
Registered: ‎08-08-2012
My Device: BlackBerry Z10
My Carrier: Rogers

Re: Try to query Supplying a status to request subscribed addresses from Blackberry push sever get malform reasponse

I think I mis-understood what you were trying to ask a few posts ago. Suspend and resume commands are only support via the server-to-server API. You can't initiate those from the device unfortunately.

Please use plain text.
Regular Contributor
martinwang
Posts: 84
Registered: ‎12-02-2009
My Device: Not Specified

Re: Try to query Supplying a status to request subscribed addresses from Blackberry push sever get malform reasponse

That means I can`t do suspend/resume by http request?
Please use plain text.
BlackBerry Development Advisor (Retired)
marco_dicesare
Posts: 76
Registered: ‎08-08-2012
My Device: BlackBerry Z10
My Carrier: Rogers

Re: Try to query Supplying a status to request subscribed addresses from Blackberry push sever get malform reasponse

That's why I mis-understood your question - yes you can do suspend/resume by HTTP request but that HTTP request must be from your push server-to-RIM push server not device-to-RIM push server

Please use plain text.
Regular Contributor
martinwang
Posts: 84
Registered: ‎12-02-2009
My Device: Not Specified

Re: Try to query Supplying a status to request subscribed addresses from Blackberry push sever get malform reasponse

Thanks, I will try it.
Please use plain text.
Regular Contributor
martinwang
Posts: 84
Registered: ‎12-02-2009
My Device: Not Specified

Re: Try to query Supplying a status to request subscribed addresses from Blackberry push sever get malform reasponse

for HTTP request from my push service,
on broswer
I try http://pushapi.na.blackberry.com/mss/PD_cpSub?cpAction=suspend&pin=XXXXXXXX;deviceside=false;Connect... on browser , I got timeout. I think it is I have to send xml format data by http post, What is xml format for suspend/Resum.? Thanks
Please use plain text.
BlackBerry Development Advisor (Retired)
marco_dicesare
Posts: 76
Registered: ‎08-08-2012
My Device: BlackBerry Z10
My Carrier: Rogers

Re: Try to query Supplying a status to request subscribed addresses from Blackberry push sever get malform reasponse

It is not an XML request. Your URL does not look correct you need to use https and you can remove the deviceside part. Also ensure you set the BASIC authorization header like you do when you initiate a push request.

 

https://<server>/mss/PD_cpSub?pin=xxxxx&cpAction=suspend

https://<server>/mss/PD_cpSub?pin=xxxxx&cpAction=resume

 

 

Please use plain text.
Regular Contributor
martinwang
Posts: 84
Registered: ‎12-02-2009
My Device: Not Specified

Re: Try to query Supplying a status to request subscribed addresses from Blackberry push sever get malform reasponse

Hi marco_dicesare,

Based your suggestion , When I suspendSubscriber, it return 1001, But I check status query, my device is still active, How can I check suspend subscriber? Thanks.
Please use plain text.
Regular Contributor
martinwang
Posts: 84
Registered: ‎12-02-2009
My Device: Not Specified

Re: Try to query Supplying a status to request subscribed addresses from Blackberry push sever get malform reasponse

Hi, marco_dicesare,

public String SuspendBBSubscriber(String deviceId, String phoneNumber, String toolName)
{
HttpWebRequest Request = null;
HttpWebResponse HttpResponse = null;
StreamReader Reader = null;


Request = (HttpWebRequest)WebRequest.Create(sUrl_suspend_resume + "?cpAction=suspend&pin=" + deviceId);
Request.Timeout = System.Threading.Timeout.Infinite;
Request.PreAuthenticate = true;
Request.ContentType = "application/xml";
string AuthInfo = UserName + ":" + UserPassword;
AuthInfo = Convert.ToBase64String(Encoding.Default.GetBytes(AuthInfo));
Request.Headers["Authorization"] = "Basic " + AuthInfo;

try
{

HttpResponse = (HttpWebResponse)Request.GetResponse();
Reader = new StreamReader(HttpResponse.GetResponseStream(), Encoding.UTF8);
Response = Reader.ReadToEnd();
StatusCode = HttpResponse.StatusCode.ToString();
StatusDescription = HttpResponse.StatusDescription;

return Response;
}
catch (WebException ex)
{
if (ex.Response != null)
{
HttpWebResponse ErrorResponse = null;
try
{
ErrorResponse = (HttpWebResponse)ex.Response;
Reader = new StreamReader(ErrorResponse.GetResponseStream());
Response = Reader.ReadToEnd();
StatusCode = ErrorResponse.StatusCode.ToString();
StatusDescription = ErrorResponse.StatusDescription;
}
finally
{
if (ex.Response != null)
ErrorResponse.Close();
}
}

return ex.Response.ToString();

}
}


I call it, it return 1001, it means The request was accepted for processing. Colud you explain to me Thanks you very much.
Please use plain text.