문제

나는 두려운 "클라이언트가"Text / HTML "의 응답 콘텐츠 유형을 발견했지만"Test / 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);
        }
    }
.

편집 :이 catch 블록의 예외가 내가 볼 수있는 것이 정확히 있지만 클라이언트 측에 System.InvalidOperationException을 여전히 얻는 것입니다.

edit2 : WebReference (* .asmx 파일 호출)를 통해 WebServices에 연결합니다.

edit3 : 여기 exceptionlog 서버 측 (publishingmanager.publish () 호출에서 exceptionlog server-side)에 기록되는 것이 있습니다. 내 생각은 이것이 고객에게 반환 된 것이어야한다는 것입니다 ...

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 :이 추가적인 코드 덩어리를 던지기를 원할 수 있도록 사람들은 내가 이러한 예외를 어떻게 테스트 하는지를 볼 수 있도록 (그리고 아마도 테스트하는 잘못된 방법이 아마 ...)됩니다. 첫 번째 코드 청크에서 시도 차단 내부에서 "Components.pwd.getConversionErrors ()를 반환합니다.", 여기에는 다음과 같은 방법이 있습니다.

    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에서 내 웹 사이트의 속성을 볼 때 "모듈"을 선택하면 웹 사이트 / 웹 서비스가 던진 오류를 처리하려는 "CustomErrorModule"이라는 항목이 있습니다.

해당 항목을 제거하거나 구성 파일을 업데이트하십시오.

다음을 수행하십시오.
<httpErrors errorMode="Custom" existingResponse="Replace">
.

to :

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

모두에게 도움을 주시면, 그것은 나를 올바른 방향으로 조종했습니다.(BTW, 나는 구성 파일을 업데이트하여 모듈 물건을 망칠 필요가 없으므로)

또한 이 상황을 설명하는 링크

다른 팁

낄낄 웃음에 대해서는 SoapException.ClientFaultCode를 사용하여 새로운 SoapException ()을 해당 통화의 유형으로 시도 할 수 있습니까?분명히, 당신이 위에 보여주는 코드에서 실패 할 수있는 몇 개의 레이어가 있으며 엉망이 쉽습니다 (나를 믿는 것, 알아, 알아 :)).Publisher.publish .. 메시지 선언 (즉, ASMX 인프라 스트럭처)인지 여부를 가리키는 다른 방법으로 다른 방법을 호출하지 마십시오.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top