none
How to get the detail of a soap fault ?

    Question

  • I receveive the following soap fault from a webserver :


    <SOAP-ENV:Fault>
      <faultcode xmlns="">SOAP-ENV:Server</faultcode>
      <faultstring xmlns="">CS8 Soap Exception</faultstring>
      <detail xmlns="">
        <fault xsi:type="SCSV0:ServerExceptionCode">INVALID-CODE-ID</fault>
      </detail>
    </SOAP-ENV:Fault>


    In my previous application I was using WSE to generates my proxy.
    The soap fault was deserialized as a SoapException and I was able to read the detail content
    (INVALID-CODE-ID in my sample)

    Now, that I'm trying to use WCF, the soap fault is no more deserialized as a SoapException but
    as a FaultException and I'm no more able to access to the detail property !

    Where can I retrieve the detail of the soap fault ?

    Thanks for your help

    Stéphane
    Thursday, March 20, 2008 10:33 AM

All replies

  • On the ServiceBehaviorAttribute on the service class set IncludeExceptionDetailsInFaults to true:

    [ServiceBehavior(
            IncludeExceptionDetailInFaults = true)]
    Thursday, March 20, 2008 11:46 AM
    Moderator
  • I defined this attribute for the client and it has no effect.
    On the server side I can't do that because it's not a wcf webservice...

    Stéphane
    Thursday, March 20, 2008 11:57 AM
  • If the server side isnt using wcf, then this really isnt a wcf service.  That attribute does only apply to the server side because it is what is sending the details.  I am not sure what the server is, but its not sending details to you and from teh client side you cant make it.  This is by design because error details can reveal information about the back end infrastructure.  A lot of system disable detials in errros and Wcf does this by default.  If you have control over the server backend you will need to figure out how to get it to send error details.  If the backend were Wcf we could help.
    Thursday, March 20, 2008 12:00 PM
    Moderator
  • The server is developped in gsoap but i'm sure that the fault detail is sent :
    the WCF client receives the soap fault that is in my firts post

    (I catpure it by activating the message logging in the app.config file)

    Thursday, March 20, 2008 12:23 PM
  • Any idea on how to convert a SoapException into FaultException ?

     

     

    Tuesday, March 25, 2008 7:30 AM
  • Have you tried catch(FaultException < SoapException > ex)?

     

    /Hakan

     

     

    Tuesday, April 22, 2008 10:18 PM
  • it doesn't work....

    The only way to catch the exception is as a FaultException.

     

    Here is the detail of the soap message that  I receive :

     

    Code Snippet
      <ApplicationData>
        <TraceData>
          <DataItem>
            <MessageLogTraceRecord Time="2008-04-23T07:58:40.9822300+02:00" Source="TransportReceive" Type="System.ServiceModel.Channels.BufferedMessage" xmlns="http://schemas.microsoft.com/2004/06/ServiceModel/Management/MessageTrace">
             '>http://schemas.microsoft.com/2004/06/ServiceModel/Management/MessageTrace">http://schemas.microsoft.com/2004/06/ServiceModel/Management/MessageTrace">
             ; <HttpResponse>
                <StatusCode>InternalServerError</StatusCode>
                <StatusDescription>Internal Server Error</StatusDescription>
                <WebHeaders>
                  <Connection>close</Connection>
                  <Content-Length>631</Content-Length>
                  <Content-Type>text/xml; charset=utf-8</Content-Type>
                  <Server>gSOAP/2.7</Server>
                </WebHeaders>
              </HttpResponse>
              <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/http://schemas.xmlsoap.org/soap/envelope/">http://schemas.xmlsoap.org/soap/envelope/</A< A>>" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/http://schemas.xmlsoap.org/soap/encoding/">http://schemas.xmlsoap.org/soap/encoding/</A< A>>" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instancehttp://www.w3.org/2001/XMLSchema-instance">http://www.w3.org/2001/XMLSchema-instance</A< A>>" xmlns:xsd="http://www.w3.org/2001/XMLSchemahttp://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchema</A< A>>" xmlns:SCSV0="CS8ServerV0">
                <SOAP-ENV:Header>
                  <SCSV0:sessionId>0</SCSV0:sessionId>
                </SOAP-ENV:Header>
                <SOAP-ENV:Body>
                  <SOAP-ENV:Fault>
                    <faultcode xmlns="">SOAP-ENV:Server</faultcode>
                    <faultstring xmlns="">CS8 Soap Exception</faultstring>
                    <detail xmlns="">
                      <fault xsi:type="SCSV0:ServerExceptionCode">INVALID-SESSION-ID-CODE</fault>
                    </detail>
                  </SOAP-ENV:Fault>
                </SOAP-ENV:Body>
              </SOAP-ENV:Envelope>
            </MessageLogTraceRecord>
          </DataItem>
        </TraceData>
      </ApplicationData>

     

     

    and I want to retrieve "INVALID-SESSION-ID-CODE"

     

    Thanks for your help

     

    Stéphane

    Wednesday, April 23, 2008 6:07 AM
  • Ok, then I don't know how to get to the Detail part. Can you add it as a regular Web Service, not WCF?

     

    /Hakan

     

    Wednesday, April 23, 2008 5:59 PM
  • no it's not possible because the server is running on VxWorks....

     

    Stéphane

     

    Thursday, April 24, 2008 7:41 AM
  •  

    I meant on the client side, when you add the web reference, instead of adding the URL as a WCF maybe you can add it as a .NET 2.0 Web service instead, on the client side.

     

    /Hakan

     

    Thursday, April 24, 2008 3:06 PM
  • I'm not sure to understand what you mean.

    In order to connect on the server, I generate a class from the WSDL using svcutil.exe.

     

    What do you mean by "add it as a .NET Web service" ?

     

    Thanks for your help

     

    Stéphane

     

    Thursday, April 24, 2008 6:10 PM
  •  

    Using wsdl.exe (or WseWsdl3.exe if you need WSE functionality) instead of svcutil.

     

    /Hakan

     

    Thursday, April 24, 2008 6:47 PM
  • How about using FaultException<T>.Detail: http://msdn2.microsoft.com/en-us/library/ms575596.aspx

    T is the fault contract you specified on the operation when defining the service.

    Friday, April 25, 2008 8:16 PM
  • The issue is that she is not in control of the service and the service is not writting in WCF, it's a regular WS/WSE.

     

    /Hakan

     

     

    Friday, April 25, 2008 8:49 PM
  • She do not need to control the service or write it in WCF, as long as the web-service follows the WSDL standard and adheres to WS-I BP 1.x rules for operations. Faults are standard stuff: each wsdl: operation should have a request message, a response message and a fault message (these are optional dependent on the MEP of the operation). The schema of the fault message is the fault contract, i.e. the details. See wsdl: fault and soap: fault elements of a wsdl: operation in the WSDL standard: http://www.w3.org/TR/wsdl

     

    If the WSDL provides the fault information, then WCF svcutil will interpret it and create a type for the details in the proxy based on the fault contract. See more details here: http://msdn2.microsoft.com/en-us/library/ms732013.aspx

     

    Saturday, April 26, 2008 7:00 AM
  • Hi Hauk,

     

    Using WseWsdl3.exe works fine but WSE seems to have bugs with MTOM !!!!

    (http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1099016&SiteID=1)

     

    I would prefer to use WCF but I'm still stuck on this problem of soap fault detail

     

    Stéphane

     

    Friday, May 23, 2008 8:24 AM
  • Hi KjellSJ

     

    I searched in my wsdl and I can't find information about the saop fault....

     

    At the beginning of my WSDL there is the following line

    Code Snippet
    xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"

     

    If I open the URL I can find the description but I don't know if it's enough for svcutil ?

     

    So my question is : How do I provide the soap fault information to svcutil ?

     

    Thanks for your help

     

    Stéphane

     

     

    Friday, May 23, 2008 8:59 AM
  • Hi Everybody,
    Does any one have solution to this issue? I am facing same issue.

    I have implemented WCF client and gSoap service(web service). I am facing one major problem if I define two level of fault message into the gSOAP service. Normally it is working fine I mean to say if I call a gSoap function using WCF client proxy, I am getting response properly through the EndPointBehaviour method(AfterReceiveRequest). But in the case of fault response I did not receive any response and showing Exception CommunicationException-Internal server error(404) however using SoapUI tool I am able to get correct multilevel subcode.
    Note- If I am not using customise fault message (two level of subcode) from gSoap service end then I am getting response of fault message in the WCF client.
    Wednesday, August 12, 2009 1:35 AM
  • This should point you in the right direction:

    catch (FaultException faultex) {
        var msgFault = faultex.CreateMessageFault();
    
        if (msgFault.HasDetail) {
            var detailNode = msgFault.GetDetail<XmlElement>();
            //detailNode is where you will find what you were looking for
        }
    }

    I know his is a few years late but this took me a full day to figure out so I hope it helps someone.
    • Proposed as answer by David_Stanley Tuesday, June 21, 2011 3:48 PM
    Friday, February 05, 2010 8:04 PM
  • Jasonkostempski, you are a life saver...
    Sunday, May 16, 2010 10:55 AM
  • More than a year later and still helping folks.  Thanks Jasonkostempski.

    Here is more info:

    http://www.codeproject.com/KB/webservices/SoapClientTest.aspx

     


    Tuesday, June 21, 2011 3:47 PM