title: Sending SOAP Request to .NET Web Service via libcurl!
body: <p>I'm Trying to send a SOAP request to a .NET Webservice which accepts an XML string. This is my sample XML string stored in char array:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"&gt;
    &lt;soap12:Body&gt;
      &lt;BankDeposit xmlns="http://tempuri.org/"&gt;
      &lt;xmlParam&gt;
          &lt;onlineTxn xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.tempuri.org/"&gt;
          &lt;TXN&gt;
              &lt;TxnID&gt;17032011111230&lt;/TxnID&gt;
              &lt;CCID&gt;73467836483&lt;/CCID&gt;
              &lt;ACNO&gt;899000777&lt;/ACNO&gt;
              &lt;TXAMT&gt;52&lt;/TXAMT&gt;
          &lt;/TXN&gt;
      &lt;/onlineTxn&gt;
      &lt;/xmlParam&gt;
      &lt;/BankDeposit&gt;
    &lt;/soap12:Body&gt;
  &lt;/soap12:Envelope&gt;
  </code></pre>
  
  <p>The code I'm using to submit to .NET webservice as follows:</p>
  
  <pre><code>int PostRequest(void)
  {
      CURL *curl;
      char buffer[2000]=//XML String to be sent.
      int res = -1;
      struct curl_httppost *post=NULL, *last=NULL;
      struct curl_slist *headers = NULL;
      unsigned int buffer_size = 2000;
  
      fp = fopen("res.xml","w");
      fpreq = fopen ("req.xml", "w");
  
      curl=curl_easy_init();
      if(curl)
      {
          headers = curl_slist_append(headers, "Content-type:application/soap+xml; charset=utf-8; action=\"http://tempuri.org/BankDeposit\"");    
          curl_easy_setopt(curl, CURLOPT_URL, URL);
          curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
          curl_easy_setopt(curl, CURLOPT_FILE, fp);
          curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data); //For writing the responses recieved 
          curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, buffer_size);
          curl_easy_setopt(curl, CURLOPT_POSTFIELDS, buffer);
  
          curl_easy_setopt(curl, CURLOPT_NOPROGRESS, FALSE);
          curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_func);    
  
          curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
          curl_easy_setopt(curl, CURLOPT_TIMEOUT, 60);
          res = curl_easy_perform(curl);  
          curl_slist_free_all(headers); 
          curl_easy_cleanup(curl);
          printf("CURL Easy Perform Status Code: %d\n", res);
      }
      fclose(fp);
      fclose(fpreq);
      return res;
  }
  </code></pre>
  
  <p>The trouble is: "The contents are not getting posted to the Web Service". I have debugged my .NET service and it doesn't receive any data from the sender.</p>
  
  <p>My Webservice operation is : BankDeposit. </p>
  
  <p>Accepts a parameter named ; xmlParam of TYPE: String</p>
  
  <p>Please help me with this. Need your suggestions.</p>