0
我试图发送和接收邮件使用任何.NET客户端API或REST API在Azure servicebus接收。邮件无法使用REST API
我按照其正常工作的REST api tutorial,我可以用这个发送和接收消息。
然而,当我发送包含使用.NET客户端,然后尝试和使用REST API得到了一个服务器的500错误与ProtocolError的状态获得这个对象我们的应用程序的自定义对象的消息。这是接收该消息的代码:
// Receives and deletes the next message from the given resource (Queue, Topic, or Subscription)
// using the resourceName, the SWT token, and an HTTP DELETE request.
private static string ReceiveAndDeleteMessage(string resourceName)
{
string fullAddress = baseAddress + resourceName + "/messages/head" + "?timeout=60";
Console.WriteLine("\nRetrieving message from {0}", fullAddress);
WebClient webClient = new WebClient();
webClient.Headers[HttpRequestHeader.Authorization] = token;
//falls over on this line
byte[] response = webClient.UploadData(fullAddress, "DELETE", new byte[0]);
string responseStr = Encoding.UTF8.GetString(response);
Console.WriteLine(responseStr);
return responseStr;
}
发送该消息的代码看起来是这样的:
Message<T> message = GetMessage();
var brokeredMessage = new BrokeredMessage(message)
{
Label = message.Label,
CorrelationId = message.RequestId.ToString(),
MessageId = Guid.NewGuid().ToString()
};
MessageSender sender = GetMessageSender();
return sender.SendAsync(brokeredMessage);
和消息对象是:
[MessageContract(WrapperName = "Message", WrapperNamespace = MessageAttributes.BaseNamespace, IsWrapped = true)]
public sealed class Message<T> where T : class
{
[MessageHeader(Namespace = MessageAttributes.BaseNamespace, Name = "RequestId")]
public Guid RequestId { get; set; }
[MessageHeader(Namespace = MessageAttributes.BaseNamespace, Name = "Label")]
public string Label { get; set; }
[MessageBodyMember(Namespace = MessageAttributes.BaseNamespace, Name = "Payload")]
public T Payload { get; set; }
[MessageBodyMember(Namespace = MessageAttributes.BaseNamespace, Name = "MonitoringResults")]
public MessageTimestamp MessageTimestamp { get; set; }
}
为什么可能这是?信息有什么不同?他们不只是我应该收到的字节流,然后反序列化回我的自定义对象?
我可以高兴地收到使用.NET客户端接收的对象。
谢谢@AbhishekLal我不知道为什么,但建立,有与该XML deserialisation的错误后(http://stackoverflow.com/questions/22152085/why-cant-i-deserialize-my -object-if-the-xml-it-contains-gets-slightly-larger)我当时没有能够重现问题,并且能够使所有工作都能正常工作 –