C#Webサービスを使用してブラックベリーでプッシュ通知を送信しようとしていますが、「リモートサーバーがエラーを返しました:(404)見つかりません。」という例外が返されるという問題が発生しています。すべての情報はRIM標準に従って正しいので、できるだけ早く助けてください。
[WebMethod] public bool push(string notification) { bool success = true; byte[] bytes = Encoding.ASCII.GetBytes("Hello"); Stream requestStream = null; HttpWebResponse HttpWRes = null; HttpWebRequest HttpWReq = null; String BESName = "cp****.pushapi.eval.blackberry.com"; try { //http://<BESName>:<BESPort>/push?DESTINATTION=<PIN/EMAIL>&PORT=<PushPort>&REQUESTURI=/ // Build the URL to define our connection to the BES. string httpURL = "https://" + BESName + "/push?DESTINATION=2B838E45&PORT=32721&REQUESTURI=/"; //make the connection HttpWReq = (HttpWebRequest)WebRequest.Create(httpURL); HttpWReq.Method = ("POST"); //add the headers nessecary for the push HttpWReq.ContentType = "text/plain"; HttpWReq.ContentLength = bytes.Length; // ******* Test this ******* HttpWReq.Headers.Add("X-Rim-Push-Id", "2B838E45" + "~" + DateTime.Now); //"~" +pushedMessage + HttpWReq.Headers.Add("X-Rim-Push-Reliability", "application-preferred"); HttpWReq.Headers.Add("X-Rim-Push-NotifyURL", ("http://" + BESName + "2B838E45~Hello~" + DateTime.Now).Replace(" ", "")); // ************************* HttpWReq.Credentials = new NetworkCredential("Username", "Password"); requestStream = HttpWReq.GetRequestStream(); //Write the data from the source requestStream.Write(bytes, 0, bytes.Length); //get the response HttpWRes = (HttpWebResponse)HttpWReq.GetResponse(); var pushStatus = HttpWRes.Headers["X-RIM-Push-Status"]; //if the MDS received the push parameters correctly it will either respond with okay or accepted if (HttpWRes.StatusCode == HttpStatusCode.OK || HttpWRes.StatusCode == HttpStatusCode.Accepted) { success = true; } else { success = false; } //Close the streams HttpWRes.Close(); requestStream.Close(); } catch (System.Exception) { success = false; } return success; }
1 に答える
0
上記のコードを試したときに同じエラーが発生しました。交換
String BESName = "cp****.pushapi.eval.blackberry.com";
と
String BESName = "cpxxx.pushapi.eval.blackberry.com/mss/PD_pushRequest";
ここで正しいユーザー名とパスワードを入力してください。
HttpWReq.Credentials = new NetworkCredential("username", "password");
私は成功しました=true;
ただし、上記のコードは正常に実行されましたが、BlackBerryデバイスにプッシュメッセージが表示されません。
于 2013-02-05T11:07:27.200 に答える