Consegui consumir com êxito a tarefa de serviços da Web no SSIS, mas não consigo descobrir como gravar no serviço da Web, alguém pode me ajudar com isso.
obrigado
Respostas:
0 para resposta № 1A pergunta é um pouco vaga demais para dar umaresposta definitiva para, mas, adivinhando o que você está perguntando, é que você conseguiu ler dados de um serviço da Web (GET), mas agora deseja gravar dados (POST / PUT) em um serviço da Web.
Nesse caso, sua melhor aposta é usar uma tarefa Script euse C # (ou VB) para chamar o referido serviço web. Também recomendo isso para solicitações GET, em oposição à tarefa de serviço web do SSIS, que "não manipula" protocolos de serviço da Web "mais recentes", como autenticação oAuth.
A amostra aproximada seria a seguinte:
using System.Net
using System.IO
string url
= "http://webservicehere.org";
// create the request
HttpWebRequest request
= (HttpWebRequest)HttpWebRequest.Create(url);
// set the method to POST
request.Method
= "POST";
// set the content type, usually application/json or application/xml
request.ContentType
= "application/json";
// handle authentication, in this case the web service
// requires the authentication token to be passed in as a
// header called "Cookie"
request.Headers.Add("Cookie", SqlAuthCookie);
// get the stream object to use to write the request data
StreamWriter requestWriter
= new StreamWriter(request.GetRequestStream());
// write the data to the web service
// where (data) is the JSON/XML that you are
// sending to the endpoint
requestWriter.Write(data);
// close the connection upon completion
requestWriter.Close();
try
{
// read the response received from the web service
HttpWebResponse webResponse = (HttpWebResponse)request.GetResponse();
// code to handle the response goes here
// i.e. deserialise json/xml to strongly typed objects
}
catch (WebException we)
{
// catch any exceptions thrown by the web service here
}
catch (Exception e)
{
// catch other exceptions here
}