.net 클라이언트 API 또는 REST API를 사용하여 Azure 서비스 버스에 메시지를 보내고 받으려고합니다..net 클라이언트 API를 사용하여 Azure servicebus로 전송 된 메시지는 나머지 api를 사용하여 수신 할 수 없습니다.
나는 잘 작동하는 REST api tutorial을 따라 왔으며이 메시지를 보내고받을 수 있습니다.
그러나 .NET 클라이언트를 사용하여 응용 프로그램의 사용자 지정 개체를 포함하는 메시지를 보낸 다음 REST API를 사용하여이 개체를 수신하면 ProtocolError 상태로 서버 500 오류가 발생합니다. 이 메시지를 수신하는 코드입니다 :
// 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 클라이언트를 사용하여 개체를받을 수 있습니다.
내가 왜하지만 XML의 deserialisation에 버그가 있다고 수립 이후 모르겠어요 @AbhishekLal 감사 (http://stackoverflow.com/questions/22152085/why-cant-i-deserialize-my -object-if-the-xml-it-contains-slightly-larger-larger) 나는 문제를 재현 할 수 없었고, 모든 것을 작동시킬 수 있었다. –