title: Accept UTF-8 encoded strings in ASP.NET WebService
body: <p>I've got a ASP.NET WebService that looks something like this:</p>
  <pre><code>[WebMethod]
  public static void DoSomethingWithStrings(string stringA, string stringB)
  {
      // and so on
  }
  </code></pre>
  <p>An third party application should call this webservice. However this application encodes strings as UTF-8 and all umlauts are replaced by '??'. I can view the call and the special characters are formatted well:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;
  &lt;!-- ... --&gt;
  &lt;SoapCall&gt;
      &lt;DoSomethingWithStrings&gt;
          &lt;stringA&gt;Ä - Ö - Ü&lt;/stringA&gt;
          &lt;stringB&gt;This is a test&lt;/stringB&gt;
      &lt;/DoSomethingWithStrings&gt;
  &lt;/SoapCall&gt;
  </code></pre>
  <p>This produces the following output, when I simply print the strings inside the webservice method:</p>
  <blockquote>
  <p>?? - ?? - ??</p>
  <p>This is a test</p>
  </blockquote>
  <p>How can I configure the WebService to accept UTF-8 encoded strings?</p>
  <p><b>Update</b></p>
  <p>Fiddler also tells me that the content-type charset of the http request is UTF-8.</p>
  <p><b>Update 2</b></p>
  <p>I tried to add following code to <code>global.asax</code> for debugging purposes:</p>
  <pre><code>public void Application_BeginRequest(object sender, EventArgs e)
  {
      using (var reader = new System.IO.StreamReader(Request.InputStream))
      {
          string str = reader.ReadToEnd();
      }
  }
  </code></pre>
  <p>This reads the actual SOAP call. The <code>StreamReader</code>s encoding is set to UTF-8. The SOAP call looks correct:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; ?&gt; 
  &lt;SOAP-ENV:Envelope xmlns:SOAP-ENV=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot;&gt;
      &lt;SOAP-ENV:Body&gt;
          &lt;DoSomethingWithStrings xmlns=&quot;http://www.tempuri.org/&quot;&gt;
              &lt;stringA&gt;Ä - Ö - Ü&lt;/stringA&gt;
              &lt;stringB&gt;This is a test!&lt;/stringB&gt;
          &lt;/DoSomethingWithStrings&gt;
      &lt;/SOAP-ENV:Body&gt;
  &lt;/SOAP-ENV:Envelope&gt;
  </code></pre>
  <p>In the <code>web.config</code> file the globalization settings are set correctly:</p>
  <pre><code>&lt;globalization requestEncoding=&quot;UTF-8&quot; responseEncoding=&quot;UTF-8&quot; culture=&quot;de-DE&quot; uiCulture=&quot;de-DE&quot; /&gt;
  </code></pre>
  <p>So it looks like something that deserializes the SOAP message does not use UTF-8 but ASCII encoding.</p>