SSIS で Web サービス タスクを使用することに成功しましたが、 Web サービスに書き込む方法がわかりません。誰かがこれを手伝ってくれますか。
ありがとう
SSIS で Web サービス タスクを使用することに成功しましたが、 Web サービスに書き込む方法がわかりません。誰かがこれを手伝ってくれますか。
ありがとう
質問は少し曖昧すぎて決定的な答えを出すことができませんが、あなたが求めていることを推測すると、Web サービス (GET) からデータを読み取ることができましたが、次は書きたい ( POST/PUT) データを Web サービスに送信します。
その場合は、スクリプト タスクを使用し、C# (または VB) を使用して上記の Web サービスを呼び出すことをお勧めします。また、oAuth 認証などの「新しい」Web サービス プロトコルを処理しない SSIS Web サービス タスクとは対照的に、GET 要求にもこれをお勧めします。
大まかなサンプルは次のようになります。
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
}