質問

恐ろしい「クライアントがレスポンスコンテンツの種類の「テキスト/ HTML」の「テキスト/ html」の「テスト/ XML」エラーが発生しましたが、いくつかのグーグルの後、この記事 SoapExceptionを返す方法について。

だから私は先に進み、それを実装しました、しかし今私はまだ同じエラーを得ています。 SoapExceptionを受け入れることができるようにクライアント側で作成する必要があるという変更があります(私はそうは思わないでしょう、すべてが例外から継承するだけです)

クライアント側でその恐ろしい応答をまだ入手しているのはなぜですか?

    [WebMethod]
    [SoapHeader("authenticationHeader")]
    [WebServiceAuthentication(AuthenticationRequired = false)]
    public DataSet GetConversionErrors()
    {
        try
        {
            return Components.PWD.GetConversionErrors();
        }
        catch (Exception ex)
        {
            PublishingManager.Publish(ex, HttpContext.Current.User.Identity.Name);
            throw Components.SoapException.GenerateSoapException(ex, Context);
        }
    }
.

編集:このキャッチブロックの例外が私が見る必要があるものであることを知っていますが、まだ私はまだclient-sideでsystem.invalidOperationExceptionを取得しています。

EDIT2:それが役立つ/重要な場合は、WebReference(* .asmxファイルを呼び出す)を介してWebサービスに接続しています。

EDIT3:これは、exceptionLogサーバー側に書かれているものです(publishingmanager.publish()呼び出し)。私の考えは、これがクライアントに返されるものであるべきだということでした...

Exception Details:
Exception Type: System.Exception
Message: Test the text/html text/xml message. 
Method: PWD.Components.PWD.GetConversionErrors 
Username: xxxxxx Created 5/22/2012 4:20:53 PM 
Application: xxxx Application Identity: NT AUTHORITY\IUSR 
Source: xxxx Severity 2 
Machine: xxxxxxxxx IP Address 127.0.0.1 
AppDomain /LM/W3SVC/1/ROOT-1-129821937733610609 
Stack Trace    at PWD.Components.PWD.GetConversionErrors() in C:\Vault\Development-New\Web\Main_Logging\PWD\Components\PWD.cs:line 73 
   at PWD.PWD.GetConversionErrors() in C:\Vault\Development-New\Web\Main_Logging\PWD\PWD.asmx.cs:line 44 
Additional Information:
  +System.Exception: 
    Message: Test the text/html text/xml message. 
    Data: System.Collections.ListDictionaryInternal 
    InnerException:  
    TargetSite: System.Data.DataSet GetConversionErrors() 
    StackTrace:    at PWD.Components.PWD.GetConversionErrors() in C:\Vault\Development-New\Web\Main_Logging\PWD\Components\PWD.cs:line 73 
   at PWD.PWD.GetConversionErrors() in C:\Vault\Development-New\Web\Main_Logging\PWD\PWD.asmx.cs:line 44 
    HelpLink:  
    Source: xxxx 
     UserName: xxxxxxx 
     TypeName: PublishingManager 
     MachineName: xxxxxxxxx 
     TimeStamp: 5/22/2012 4:20:54 PM 
     FullName: Services.Publishing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=null 
     AppDomainName: /LM/W3SVC/1/ROOT-1-129821937733610609 
     ThreadIdentity:  
     WindowsIdentity: NT AUTHORITY\IUSR 
     Severity: 2 
     MachineIPAddress: 127.0.0.1 
.

edit3:この余分なコードチャンクを投げたいだけで、人々はこれらの例外をテストしているのかを見て(そしてそれはテストする間違った方法です)。私の最初のコードチャンクでは、私はtryブロック内で "components.pwd.getconvegionerrors()を返す"の呼び出しを持っています。これは、その方法です:

    public static DataSet GetConversionErrors()
    {
        DB db = new DB();

        try
        {
            //return db.ExecuteDataset(Configuration.GenericConfig.AppConnectionString, CommandType.Text, spGetConversionErrors);
            throw new Exception("Test the text/html text/xml message.");
        }
        catch
        {
            throw;
        }
    }
.

あなたが見ることができるように、私は実際の通話をコメントアウトし、テスト目的のために毎回例外をスローする私自身の行を投げました...

EDIT4:@GBVBこれは新しいメソッドです:

    [WebMethod]
    [SoapHeader("authenticationHeader")]
    [WebServiceAuthentication(AuthenticationRequired = false)]
    public DataSet GetConversionErrors()
    {
        try
        {
            return Components.PWD.GetConversionErrors();
        }
        catch (Exception ex)
        {
            //PublishingManager.Publish(ex, HttpContext.Current.User.Identity.Name);
            //throw Components.SoapException.GenerateSoapException(ex, Context);

            System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
            System.Xml.XmlNode detailNode = xmlDoc.CreateNode(System.Xml.XmlNodeType.Element, System.Web.Services.Protocols.SoapException.DetailElementName.Name, System.Web.Services.Protocols.SoapException.DetailElementName.Namespace);
            detailNode.InnerText = ex.ToString();

            throw new System.Web.Services.Protocols.SoapException(ex.Message, System.Web.Services.Protocols.SoapException.ClientFaultCode, System.Web.HttpContext.Current.Request.Url.AbsoluteUri, detailNode, ex.InnerException);
        }
    }
.

EDIT5:どんなFiddler2を見た:

HTTP/1.1 500 Internal Server Error
Cache-Control: private
Content-Type: text/html
Server: Microsoft-IIS/7.5
X-Powered-By: ASP.NET
Date: Wed, 23 May 2012 19:25:56 GMT
Content-Length: 1208

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>500 - Internal server error.</title>
<style type="text/css">
<!--
body{margin:0;font-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;}
fieldset{padding:0 15px 10px 15px;} 
h1{font-size:2.4em;margin:0;color:#FFF;}
h2{font-size:1.7em;margin:0;color:#CC0000;} 
h3{font-size:1.2em;margin:10px 0 0 0;color:#000000;} 
#header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet MS", Verdana, sans-serif;color:#FFF;
background-color:#555555;}
#content{margin:0 0 0 2%;position:relative;}
.content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;}
-->
</style>
</head>
<body>
<div id="header"><h1>Server Error</h1></div>
<div id="content">
 <div class="content-container"><fieldset>
  <h2>500 - Internal server error.</h2>
  <h3>There is a problem with the resource you are looking for, and it cannot be displayed.</h3>
 </fieldset></div>
</div>
</body>
</html>
.

誰かがこのセクションを正しくフォーマットしてきている場合は、してください。)

役に立ちましたか?

解決

だから、私はそれを働かせました。これが私が見つけたものです:

IISでの私のウェブサイトのプロパティを表示するときは、「モジュール」を選択すると、Webサイト/ Webサービスによってスローされているエラーを処理しようとしている「CustomerRormodule」というエントリがあります。

修正プログラムは、そのエントリ "CustomerRormodule"を削除するか、または私の構成ファイルを更新するか:

<httpErrors errorMode="Custom" existingResponse="Replace">
.

to:

<httpErrors errorMode="Custom" existingResponse="Auto">
.

誰もが助けてくれてありがとう、それは私を正しい方向に操縦しました。(BTW、私は構成ファイルを更新していますので、モジュールのものを混乱させる必要はありません)

また、ここにリンクこの状況を説明します。

他のヒント

gigglesのために、SoapException.ClientFaultCodeをその呼び出しから種類として明示的に投げてみることができますか?明らかに、あなたが上に見せるコードで失敗する可能性があるいくつかのレイヤーを持っていて、それは簡単に台無しにするのが簡単です(私を知っています:))。そして、Publisher.Publishなどの他の方法を呼び出さないでください。それはメッセージ宣言(すなわちASMXインフラストラクチャ)かどうかを指しているか、それとも例外とめちゃくちゃにめちゃくちゃになっているかを指します..

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top