Meu codigo faz um post para uma webapi apartir de um gatilho em uma SP que monitora meu banco.
Esse POST funciona bem para msgs de até 4000 caracteres mas acima disso a SP da este erro:
"ERRO -> 9521 ultrapassa o tamanho máximo de mensagens aceito de 4.000."
SP:
CREATE PROCEDURE TESTE_SP_TransactionNotification
@object_type nvarchar(20),
@transaction_type nchar(1),
@list_of_key_cols_tab_del nvarchar(max),
@list_of_cols_val_tab_del nvarchar(max),
@ErrorNumber int output,
@ErrorDescription nvarchar(4000) output
as EXTERNAL NAME [Xnet.Atelie.Integration.Clr].
[Clr.StoredProcedures].[TESTE_SP_TransactionNotification]
Código POST .NET
protected string POST([SqlFacet(MaxSize = -1)]string message, string url, string routerKey)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "POST";
SqlContext.Pipe.Send("Send::: " + message);
var messageBytes = Convert.ToBase64String(Encoding.UTF8.GetBytes(message));
var send = "{\"exchange\":\"" + this.Exchange + "\", \"routerKey\":\"" + routerKey + "\", \"content\": \"" + messageBytes + "\" }";
SqlContext.Pipe.Send(send);
request.ContentType = "application/json";
request.ContentLength = Encoding.UTF8.GetBytes(send).Length;
using (var dataStream = request.GetRequestStream())
{
dataStream.Write(Encoding.UTF8.GetBytes(send), 0, Encoding.UTF8.GetBytes(send).Length);
dataStream.Close();
using (var response = (HttpWebResponse)request.GetResponse())
{
SqlContext.Pipe.Send(response.StatusDescription);
var responseFromServer = response.StatusDescription;
response.Close();
SqlContext.Pipe.Send(responseFromServer);
return responseFromServer;
}
}
}