title: "Specified value has invalid HTTP Header characters. Parameter name: name"
body: <p>I'm trying to build a soap envelope using C#; I'm getting the error: "Specified value has invalid HTTP Header characters. Parameter name: name" when adding the header.
  When I use the Immediate Window to examine the output of BuildSoapHeader(), I still see the escape sequence "\" literal and I wonder if that's the issue or if it's something else.</p>
  
  <p>Please help!</p>
  
  <pre><code>WebRequest webRequest = WebRequest.Create(this._fiserveURI);
  HttpWebRequest httpRequest = (HttpWebRequest)webRequest;
  httpRequest.Method = "POST";
  httpRequest.ContentType = "text/xml; charset=utf-8";
  httpRequest.Headers.Add(this.BuildSoapHeader());
  ...
  
      private string BuildSoapHeader()
      {
          StringBuilder retValue = new StringBuilder("&lt;SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" ");
          retValue.Append("xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\" ");
          retValue.Append("xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" ");
          retValue.Append("xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"&gt; ");
          retValue.Append("&lt;SOAP-ENV:Header&gt;");
          retValue.Append("&lt;m:PI00WEBSOperationRequest_header xmlns:m=\"http://www.FiservLSP.RequestHeader.com\"&gt;");
          retValue.Append("&lt;m:LSPHeader&gt;");
          retValue.Append("&lt;m:Service&gt;");
          retValue.Append("&lt;m:DateTime&gt;" + DateTime.Now.ToString() + "&lt;/m:DateTime&gt;");
          retValue.Append("&lt;m:uuid&gt;" + this._fiserveUUID +"&lt;/m:uuid&gt;");
          retValue.Append("&lt;/m:Service&gt;");
          retValue.Append("&lt;m:Security&gt;");
          retValue.Append("&lt;m:AuthenticationMaterial&gt;");
          retValue.Append("&lt;m:PrincipalPWD&gt;" + this._fiservePrincipalPWD + "&lt;/m:PrincipalPWD&gt;");
          retValue.Append("&lt;m:PrincipalID&gt;"+ this._fiservePrincipalID +"&lt;/m:PrincipalID&gt;");
          retValue.Append("&lt;/m:AuthenticationMaterial&gt;");
          retValue.Append("&lt;/m:Security&gt;");
          retValue.Append("&lt;m:Client&gt;");
          retValue.Append("&lt;m:VendorID&gt;" + this._fiserveVendorID + "&lt;/m:VendorID&gt;");
          retValue.Append("&lt;m:AppID&gt;" + this._fiserveAppID + "&lt;/m:AppID&gt;");
          retValue.Append("&lt;m:OrgID&gt;" + this._fiserveOrgID + "&lt;/m:OrgID&gt;");
          retValue.Append("&lt;m:SessionID&gt;" + this._fiserveSessionID + "&lt;/m:SessionID&gt;");
          retValue.Append("&lt;/m:Client&gt;");
          retValue.Append("&lt;m:DataSource&gt;");
          retValue.Append("&lt;m:URI&gt;" + this._fiserveURI + "&lt;/m:URI&gt;");
          retValue.Append("&lt;/m:DataSource&gt;");
          retValue.Append("&lt;/m:LSPHeader&gt;");
          retValue.Append("&lt;/m:PI00WEBSOperationRequest_header&gt;");
          retValue.Append("&lt;/SOAP-ENV:Header&gt;");
          //retValue.Append("&lt;SOAP-ENV:Body&gt;&lt;/SOAP-ENV:Body&gt;");
          retValue.Append("&lt;/SOAP-ENV:Envelope&gt;");
          return retValue.ToString();
      }
  </code></pre>