title: Soap Request keeps sending wrong value
body: <p>I have created a small soap application which calls a service. The application reads a script file, splits the params, and replaces placeholders in a soap request body template.</p>
  
  <p>(abbreviated for length)</p>
  
  <pre><code>&lt;soap:Envelope...&gt;
    ...
    &lt;param1&gt;?&lt;/param&gt;
    ...
  &lt;/soap:Envelope...&gt;
  </code></pre>
  
  <p>The script would look like </p>
  
  <pre><code>myAction|50|...
  </code></pre>
  
  <p>and the tool takes care of replacing ? with 50 in the correct spot.</p>
  
  <p>My problem comes when I want to send nothing for a param.</p>
  
  <pre><code>MyAction||....
  </code></pre>
  
  <p>I am just doing a string.Split(), the resulting array says the [1] == string.Empty</p>
  
  <p>Replacing is like so (endtag is defined outside the loop so it progresses though the body)</p>
  
  <pre><code> var endtag = body.IndexOf("&lt;/" + param + "&gt;", endtag)
   var beg = body.Substring(0, endtag - 1);
   body = beg + param + body.Substring(endtag);
  </code></pre>
  
  <p>Looking at the resulting body, everything looks fine:</p>
  
  <pre><code>&lt;soap:Envelope...&gt;
    ...
    &lt;param1&gt;&lt;/param&gt;
    ...
  &lt;/soap:Envelope...&gt;
  </code></pre>
  
  <p>However, when my service receives it the string param1 has "\n     "</p>
  
  <p>I can't figure out why this replacement is occurring. </p>
  
  <p>Any ideas are appreciated.</p>