Wie kann der Fehler 'Client hat Antwortinhaltstyp' text / html 'gefunden ... interpretiert werden?

Ich verwende C # und stelle über ein automatisch generiertes C # -Proxyobjekt eine Verbindung zu einem WebService her. Die Methode, die ich aufrufe, kann lange dauern und manchmal auch ausfallen. Ich bekomme verschiedene Fehler zurück, manchmal bekomme ich einenSystem.Net.WebException oder einSystem.Web.Services.Protocols.SoapException. Diese Ausnahmen haben Eigenschaften, die ich abfragen kann, um den spezifischen Fehlertyp zu ermitteln, von dem ich dem Benutzer eine benutzerfreundliche Version anzeigen kann.

Aber manchmal bekomme ich einfach eineInvalidOperationExceptionund es hat die folgende Meldung. Gibt es eine Möglichkeit, das zu interpretieren, ohne die Zeichenfolge nach Dingen zu durchsuchen, die ich erkenne, die sich sehr schmutzig anfühlen und die nicht internationalisierungsunabhängig sind? Die Fehlermeldung wird möglicherweise in einer anderen Sprache zurückgegeben.

Client found response content type of 'text/html; charset=utf-8', but expected 'text/xml'.
The request failed with the error message:
--
<html>
    <head>
    <title>Request timed out.</title>
                        <style>
         body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;} 
         p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px}
         b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px}
         H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }
         H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon }
         pre {font-family:"Lucida Console";font-size: .9em}
         .marker {font-weight: bold; color: black;text-decoration: none;}
         .version {color: gray;}
         .error {margin-bottom: 10px;}
         .expandable { text-decoration:underline; font-weight:bold;     color:navy;         cursor:hand; }
        </style>
    </head>

    <body bgcolor="white">

            <span><H1>Server Error in '/PerformanceManager' Application.<hr     width=100% size=1 color=silver></H1>

            <h2> <i>Request timed out.</i> </h2></span>

            <font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif ">

            <b> Description: </b>An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

            <br><br>

            <b> Exception Details: </b>System.Web.HttpException: Request timed out.<br><br>

            <b>Source Error:</b> <br><br>

            <table width=100% bgcolor="#ffffcc">
               <tr>
                  <td>
                      <code>

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.</code>

                  </td>
               </tr>
            </table>

            <br>

            <b>Stack Trace:</b> <br><br>

            <table width=100% bgcolor="#ffffcc">
                   <tr>
                  <td>
                      <code><pre>

[HttpException (0x80004005): Request timed out.]
</pre></code>

                  </td>
               </tr>
            </table>

            <br>

            <hr width=100% size=1 color=silver>

            <b>Version Information:</b> Microsoft .NET Framework Version:2.0.50727.312; ASP.NET Version:2.0.50727.833

            </font>

    </body>
</html>
<!-- 
[HttpException]: Request timed out.
-->
--.

Edit: Ich habe einen Try-Catch um die Methode auf dem Webserver. Ich habe es getestet und die Webservermethode kehrt ausnahmslos (nach ungefähr einer Minute) zurück. Ich habe auch einen unbehandelten Exception-Handler im Web-Service hinzugefügt und einen Haltepunkt, der nicht getroffen wurde. Sobald der Webdienst zurückkehrt, erhalte ich diesen Fehler im Client anstelle des erwarteten Ergebnisses.

Antworten auf die Frage(9)

Ihre Antwort auf die Frage