将消息添加到不具有base64编码的azure存储队列中? [英] Add message to azure storage queue without base64 encoding?

查看:61
本文介绍了将消息添加到不具有base64编码的azure存储队列中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法将我的请求编码为base64,根据文档,我不必这样做,但我无法弄清楚.

I don't have the possibility to encode my request to base64, and according to the documentation I shouldn't have to, but I can't figure it out.

如果我对Base64进行编码,则可以正常工作:

If I Base64 encode it's working fine:

<QueueMessage>
<MessageText>PHNhbXBsZT5zYW1wbGUgbWVzc2FnZTwvc2FtcGxlPg==</MessageText>
</QueueMessage>

将已解码的消息添加到队列中

Which adds the decoded message to the queue:

<sample>sample message</sample>

根据文档( https://msdn.microsoft.com/sv-se/library/azure/dd179346.aspx )

消息必须采用可包含在XML请求中的格式使用UTF-8编码.为了在消息中包含标记,该消息必须是XML转义的或Base64编码的.任何XML未转义或编码的邮件中的标记将被删除在将消息添加到队列之前.

A message must be in a format that can be included in an XML request with UTF-8 encoding. To include markup in the message, the contents of the message must either be XML-escaped or Base64-encode. Any XML markup in the message that is not escaped or encoded will be removed before the message is added to the queue.

尝试添加(而不是PHNhbXBsZT5zYW1wbGUgbWVzc2FnZTwvc2FtcGxlPg ==):

Trying to add (instead of PHNhbXBsZT5zYW1wbGUgbWVzc2FnZTwvc2FtcGxlPg==):

&lt;sample&gt;sample message&lt;/sample&gt;

成功,但是当尝试查看队列中的消息时,它仅响应:

Succeeds but when trying to view the message in the queue it only responds with:

输入不是有效的Base-64字符串,因为它包含非base 64字符串字符,两个以上的填充字符或非法字符在填充字符之间.

The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters.

有人知道如何向存储队列发送正确的原始xml转义请求消息吗?

Does somebody know how send a proper raw xml-escaped request message to the storage queue?

完整请求(不包含键和名称):

Full request (without keys and names):

POST https://xxxxxxx.queue.core.windows.net/testqueue/messages?sv=2015-04-05&ss=q&srt=sco&sp=a&se=2026-11-11T20:24:03Z&st=2016-11-11T12:24:03Z&spr=https&sig=xxxxxxxxxxxxxxxxx%3D HTTP/1.1
User-Agent: Fiddler
Host: XXXXX.queue.core.windows.net
Content-Type: text/plain
Content-Length: 64

<QueueMessage>
<MessageText>&lt;sample&gt;sample message&lt;/sample&gt;</MessageText>
</QueueMessage>

推荐答案

我在调用AsString属性时遇到格式错误,因为从存储队列返回的消息默认情况下是base64编码的.

I was getting format errors calling the AsString property because the message returned from the storage queue was, by default, base64 encoded.

CloudQueue对象的EncodeMessage属性设置为true.将其切换为false,一切正常.这是我的代码:

The CloudQueue object has an EncodeMessage property that was set to true. Switched it to false and everything worked. Here's my code:

 CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient();
 CloudQueue queue = queueClient.GetQueueReference(ClientQueueName);
 queue.EncodeMessage = false;
 CloudQueueMessage retrievedMessage = queue.GetMessage();

ClientQueueName是一个字符串,其中包含我在Azure上的队列名称.我认为您也需要在发送前将该属性设置为false.

ClientQueueName being a string holding the name of my queue on Azure. I'm thinking that the property needs to be set to false in your case before sending as well.

这篇关于将消息添加到不具有base64编码的azure存储队列中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆