public void AddMessage(CloudQueueMessage message, Action<CloudOperationResponse<bool>> callback) { if (message == null) throw new ArgumentNullException("message", "The message cannot be null."); var requestUri = BuildUri(this.Uri, "messages", string.Empty); var request = this.ResolveRequest(requestUri); request.Method = "POST"; var xmlData = string.Format(CultureInfo.InvariantCulture, "<QueueMessage><MessageText>{0}</MessageText></QueueMessage>", Convert.ToBase64String(message.AsBytes)); this.SendRequest(request, Encoding.UTF8.GetBytes(xmlData), HttpStatusCode.Created, r => true, callback); }
public void DeleteMessage(CloudQueueMessage message, Action<CloudOperationResponse<bool>> callback) { if (message == null) throw new ArgumentNullException("message"); if (string.IsNullOrWhiteSpace(message.Id)) throw new ArgumentNullException("message", "The message id cannot be null nor empty."); if (string.IsNullOrWhiteSpace(message.PopReceipt)) throw new ArgumentNullException("message", "The message must be retrieved from a queue in order to delete it."); var requestUri = BuildUri(this.Uri, BuilUriPath("messages", message.Id), string.Concat("popreceipt=", HttpUtility.UrlEncode(message.PopReceipt))); var request = this.ResolveRequest(requestUri); request.Method = "DELETE"; this.SendRequest(request, HttpStatusCode.NoContent, r => true, callback); }