根据MSDN,可以通过REST API提交Brokered Message,这个代理消息可以将Properties键值对作为消息的一部分.我已经能够提交Brokered消息,但是当我收到消息时,消息中的Properties字段不会被填充.我必须错误地编码Properties JSON.
这是代码片段
WebClient webClient = new WebClient();
webClient.Headers[HttpRequestHeader.Authorization] = _token;
webClient.Headers["Content-Type"] = "application/atom+xml;type=entry;charset=utf-8";
Guid messageId = Guid.NewGuid();
webClient.Headers["BrokerProperties"] = @"{""MessageId"": ""{" + messageId.ToString("N") + @"}"", ""TimeToLive"" : 900, ""Properties"": [{""Key"" : ""ProjectId"", ""Value"" : """ + message.ProjectId + @"""}]}";
// Serialize the message
MemoryStream ms = new MemoryStream();
DataContractSerializer ser = new DataContractSerializer(typeof(RespondentCommitMessage));
ser.WriteObject(ms, message);
byte[] array = ms.ToArray();
ms.Close();
byte[] response = webClient.UploadData(fullAddress, "POST", array);
string responseStr = Encoding.UTF8.GetString(response);
Run Code Online (Sandbox Code Playgroud)
有没有人有使用BrokerProperties HTTP标头提交BrokeredMessage的示例?
看起来 servicebus 团队已经在http://servicebus.codeplex.com/上的 Codeplex 上发布了一些 silverlight 和 Windows Phone 服务总线示例。我快速查看了 silverlight 聊天示例的代码,它似乎拥有通过 RESTFull API 发布代理消息所需的一切。
| 归档时间: |
|
| 查看次数: |
2542 次 |
| 最近记录: |