title: Capturing the soap request/response from a webservice
body: <p>I am working on an SSIS package that uses a c# script task. For debugging and logging I would like to capture the soap request/response from the webservice.</p>
  
  <p>Now is this something I have never had to do before and I am a bit stuck with where to go. 
  I am using .Net's built in support for webservices and the generated proxy class.</p>
  
  <p>Any help with this is greatly appreciated.</p>
  
  <p>Here is my current code:</p>
  
  <pre><code>public void Main()
  {
      try
      {
          DataTable dt = new DataTable();
          OleDbDataAdapter oleDa = new OleDbDataAdapter();
          ArrayList itemArray = new ArrayList();
          ArrayList orderArray = new ArrayList();
  
          oleDa.Fill(dt, Dts.Variables["User::ZBatch_Order_Export_ResultSet"].Value);
  
          int i = 0;
          foreach (DataRow row in dt.Rows)
          {
              orderArray.Add(ConstructOrderTransaction(row));
              itemArray.Add(ConstructItemTransaction(row));
              i++;
          }
  
          ZBatch_PublisherService.ZBatchPublisherServiceService ws = new ZBatchPublisherServiceService();
          ZBatch_PublisherService.bcfItemTransaction[] itemObjects = itemArray.ToArray() as bcfItemTransaction[];
          ZBatch_PublisherService.bcfOrderTransaction[] orderObjects = orderArray.ToArray() as bcfOrderTransaction[];
          ZBatch_PublisherService.zBatchResults results = new zBatchResults();
  
          results = ws.saveBatch(orderObjects, itemObjects);
  
          Dts.TaskResult = (int)ScriptResults.Success;
      }
      catch (Exception e)
      {
          Dts.Events.FireError(0, "ZBatch - Script Task", e.Message.ToString(), string.Empty, 0);
  
          // do some logging of this error message
      }
  }
  </code></pre>