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
Accepted Solution

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

I try to do Supplying a status to request subscribed addresses

RUL is:

https://pushapi.na.blackberry.com/mss/PD_cpSubQuery

pap xml request message is:

<?xml version="1.0"?>
 <!DOCTYPE pap PUBLIC "-//WAPFORUM//DTD PAP 2.1//EN"
"http://www.openmobilealliance.org/tech/DTD/pap_2.1.dtd">
<bpds version="1.0">
    <subscriptionquery-message pushservice-id="32-C9ViiTf34OTf7yigCHZZ">
        <status status-value="active"/>
    </subscriptionquery-message>
</bpds>

method is post,
I got respone is:

<bpds version="1.0"><badmessage-response event-time="2012-09-20T18:04:23Z" code="22000" desc="Not understood due to malformed syntax."/></bpds>

I can not find where is format invalid

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

Try removing the !DOCTYPE element so instead HTTP post this:

 

<bpds version="1.0">

    <subscriptionquery-message pushservice-id="<your push service id>">

        <status status-value="active"/>

    </subscriptionquery-message>

</bpds>

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

I remove !DOCTYPE element
call web server By https://pushapi.na.blackberry.com/mss/PD_cpSubQuery. I got same error,
If Call web sever by http://pushapi.na.blackberry.com/mss/PD_cpSubQuery, I got unable connect remote web server.

I call it from DOT.NET web service.
Do I need call in content provider ( push initiator) context?
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 am not sure I understand your question. You should make this calll from your server-side push initiator application.

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,

I call from DOT.NET web service using http post request
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

I post My web service method in DOT.NET web service


public string GetAllActiveSubscriptions()
{
HttpWebRequest Request = null;
HttpWebResponse HttpResponse = null;
StreamReader Reader = null;
string Boundary = "mPsbVQo0a68eIL3OAxnm";
StatusCode = "";
StatusDescription = "";
PushResultCode = "";
PushResultDesc = "";

Request = (HttpWebRequest)WebRequest.Create(sUrl_sub);
Request.Method = "POST";
Request.Timeout = System.Threading.Timeout.Infinite;
Request.PreAuthenticate = true;
Request.ContentType = "multipart/related; type=application/xml";
string AuthInfo = UserName + ":" + UserPassword;
AuthInfo = Convert.ToBase64String(Encoding.Default.GetBytes(AuthInfo));
Request.Headers["Authorization"] = "Basic " + AuthInfo;
StringBuilder Data = new StringBuilder();

string DeliverBefore = System.DateTime.Now.ToUniversalTime().AddMinutes(100).ToString("s", System.Globalization.CultureInfo.InvariantCulture) + "Z";

// Data.AppendLine("--" + Boundary);
// Data.AppendLine("Content-Type: application/xml; charset=utf-8");
Data.AppendLine("");
Data.AppendLine("<?xml version=\"1.0\"?>");
// Data.AppendLine("<!DOCTYPE pap PUBLIC \"-//WAPFORUM//DTD PAP 2.1//EN\" \"http://www.openmobilealliance.org/tech/DTD/pap_2.1.dtd\">");
Data.AppendLine("<bpds version=\"1.0\" >");
// Data.AppendLine("<pap >");
Data.AppendLine("<subscriptionquery-message pushservice-id=\"" + ApplicationId + "\">");
Data.AppendLine("<status status-value=\"active\"/>");

Data.AppendLine("</subscriptionquery-message>");
// Data.AppendLine("</pap>");
Data.AppendLine("</bpds>");
// Data.AppendLine("--" + Boundary);
Data.AppendLine("");
try
{
byte[] PostBytes = Encoding.Default.GetBytes(Data.ToString());
Stream RequestStream = Request.GetRequestStream();
RequestStream.Write(PostBytes, 0, PostBytes.Length);
RequestStream.Close();
HttpResponse = (HttpWebResponse)Request.GetResponse();
Reader = new StreamReader(HttpResponse.GetResponseStream(), Encoding.UTF8);
Response = Reader.ReadToEnd();
StatusCode = HttpResponse.StatusCode.ToString();
StatusDescription = HttpResponse.StatusDescription;
/* if (StatusCode.ToLower() == "ok")
{
XmlDocument XmlDoc = new XmlDocument();
XmlDoc.LoadXml(Response);
XmlNode node = XmlDoc.SelectSingleNode("subscriptionquery-detail");
if (node != null)
{
for (int i = 0; i < node.Attributes.Count - 1; i++)
{
if (node.Attributes[i].Name == "code")
PushResultCode = node.Attributes[i].Value;
if (node.Attributes[i].Name == "desc")
PushResultDesc = node.Attributes[i].Value;
}
}
return Response;
}*/
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 "";

}
}
Could help me check where is wrong?

Thanks very much
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

Can you try and set your content-type to be: "application/xml" only and see what happens?

 

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

After change Data.AppendLine("Content-Type: application/xml");
with https
I got response:
<GetAllActiveSubscriptionsResponse>
<GetAllActiveSubscriptionsResult>
<bpds version="1.0">
<badmessage-response event-time="2012-09-25T15:12:32Z" code="22000" desc="Not understood due to malformed syntax."/></bpds>
</GetAllActiveSubscriptionsResult>
</GetAllActiveSubscriptionsResponse>

with http
resonse: connect remote sever time out

same as before
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

You must use https, http will not work. I don't think you got it quite right change:

 

Request.ContentType = "multipart/related; type=application/xml"; to just "application/xml" and comment out


// Data.AppendLine("Content-Type: application/xml; charset=utf-8");

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

Here is my modified function

public string GetAllActiveSubscriptions()
{
HttpWebRequest Request = null;
HttpWebResponse HttpResponse = null;
StreamReader Reader = null;
string Boundary = "mPsbVQo0a68eIL3OAxnm";
StatusCode = "";
StatusDescription = "";
PushResultCode = "";
PushResultDesc = "";

Request = (HttpWebRequest)WebRequest.Create(sUrl_sub);
Request.Method = "POST";
Request.Timeout = System.Threading.Timeout.Infinite;
Request.PreAuthenticate = true;
// Request.ContentType = "multipart/related; type=application/xml";
Request.ContentType = "application/xml";
string AuthInfo = UserName + ":" + UserPassword;
AuthInfo = Convert.ToBase64String(Encoding.Default.GetBytes(AuthInfo));
Request.Headers["Authorization"] = "Basic " + AuthInfo;
StringBuilder Data = new StringBuilder();

string DeliverBefore = System.DateTime.Now.ToUniversalTime().AddMinutes(100).ToString("s", System.Globalization.CultureInfo.InvariantCulture) + "Z";

// Data.AppendLine("--" + Boundary);
// Data.AppendLine("Content-Type: application/xml; charset=utf-8");
Data.AppendLine("");
Data.AppendLine("<?xml version=\"1.0\"?>");
// Data.AppendLine("<!DOCTYPE pap PUBLIC \"-//WAPFORUM//DTD PAP 2.1//EN\" \"http://www.openmobilealliance.org/tech/DTD/pap_2.1.dtd\">");
Data.AppendLine("<bpds version=\"1.0\" >");
// Data.AppendLine("<pap >");
Data.AppendLine("<subscriptionquery-message pushservice-id=\"" + ApplicationId + "\">");
Data.AppendLine("<status status-value=\"active\"/>");

Data.AppendLine("</subscriptionquery-message>");
// Data.AppendLine("</pap>");
Data.AppendLine("</bpds>");
// Data.AppendLine("--" + Boundary);
Data.AppendLine("");
try
{
byte[] PostBytes = Encoding.Default.GetBytes(Data.ToString());
Stream RequestStream = Request.GetRequestStream();
RequestStream.Write(PostBytes, 0, PostBytes.Length);
RequestStream.Close();
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 "";

}
}


I try it , I got same result as before
Please use plain text.