Note that there are some explanatory texts on larger screens.

plurals
  1. POWebServices fail because (400) Bad Request because of special character
    text
    copied!<p>Using Visual Studio 2008, I setup a client that uses Web Services. It has nothing to do with buffer sizes (as that is a typical response, all appropriate sizes were increased).</p> <p>I was using a List as the parameter of the Method. After much experimentation, I used the System.Net.WebClient to manually create a Soap 1.1 and a Soap 1.2 request to test test the result.</p> <pre><code>using (var webCtx = new System.Net.WebClient()) { webCtx.Headers.Add(System.Net.HttpRequestHeader.ContentType, "text/xml"); webCtx.Headers.Add("SOAPAction", "http://tempuri.org/HelloWorld"); var uri = new Uri("http://localhost:12345/MyProject/WebService.asmx"); MessageBox.Show(webCtx.UploadString(uri, xml)); } </code></pre> <p>Where the xml is a string variable of the xml with actual data. The problem is when one of the fields has a special character. Here is the example of the message body of the xml.</p> <pre><code>&lt;PocoClass&gt; &lt;UnicodeString&gt;&amp;#xE;123&lt;/UnicodeString&gt; &lt;/PocoClass&gt; </code></pre> <p>If the value of UnicodeString was something simple (i.e. 123), but once the special character appeared, I got 400 Bad Request.</p> <p>Now, I have found a Microsoft Knowledge Base Article describing the bug <a href="http://support.microsoft.com/kb/911276/en-us" rel="nofollow noreferrer">kb911276</a>, which basically states, install a hot fix. That really isn't something that can be a solution to the problem, so I was wondering if there are any ideas of how to solve this problem?</p> <p>Are the only solutions to write some sort of custom encoding/decoding or custom bindings to be implemented by the server and client? Are there any easier ideas?</p> <p>Thanks</p> <p><em>Edited:</em> The use of a List is not an issue as it is handled by VS. Here is a more complete (but still partial) contents of the soap message.</p> <pre><code>&lt;HelloWorld xmlns="http://tempuri.org/"&gt; &lt;pocoList&gt; &lt;PocoClass&gt; &lt;UnicodeString&gt;&amp;#xE;123&lt;/UnicodeString&gt; &lt;/PocoClass&gt; &lt;/pocoList&gt; &lt;/HelloWorld&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload