Results 1 to 4 of 4

Thread: System.ServiceModel.FaultException Error

  1. #1
    Join Date
    May 2009
    Posts
    543

    System.ServiceModel.FaultException Error

    I have a test app that emulates the data that the Client would pass to the back end that my company uses for WCF back end. But when i am writing the following fault exception on my server side it is giving me the following error.Could anyone tell me what is System.ServiceModel.FaultException ?

  2. #2
    Join Date
    Apr 2008
    Posts
    2,565

    Re: System.ServiceModel.FaultException Error

    FaultException is used in a client application to catch contractually-specified SOAP faults. Exceptions are technology specific and therefore not suitable to cross the service boundary of SOA compliant services. Another anomaly we identified is that all exceptions, with the exception of FaultException fault the communication channel, resulting in unhappy proxies as a recover and retry is not possible.Typical deployed services use the FaultContractAttribute to formally specify all SOAP faults that a client can expect to receive in the normal course of an operation. Error information in a FaultContractAttribute appears as a FaultException when it arrives at a client application.

    The FaultContractAttribute can be used to specify SOAP faults for both two-way service methods and for asynchronous method pairs.The following code example shows how a service uses the FaultException type to throw a managed exception that gets converted into the SOAP fault specified by the FaultContractAttribute.

    C#
    using System;
    using System.Collections.Generic;
    using System.Net.Security;
    using System.Runtime.Serialization;
    using System.ServiceModel;
    using System.Text;

    namespace Microsoft.WCF.Documentation
    {
    [ServiceContract(Namespace="http://microsoft.wcf.documentation")]
    public interface ISampleService{
    [OperationContract]
    [FaultContractAttribute(
    typeof(GreetingFault),
    Action="http://www.contoso.com/GreetingFault",
    ProtectionLevel=ProtectionLevel.EncryptAndSign
    )]
    string SampleMethod(string msg);
    }

    [DataContractAttribute]
    public class GreetingFault
    {
    private string report;

    public GreetingFault(string message)
    {
    this.report = message;
    }

    [DataMemberAttribute]
    public string Message
    {
    get { return this.report; }
    set { this.report = value; }
    }
    }

    class SampleService : ISampleService
    {
    #region ISampleService Members

    public string SampleMethod(string msg)
    {
    Console.WriteLine("Client said: " + msg);
    // Generate intermittent error behavior.
    Random rand = new Random(DateTime.Now.Millisecond);
    int test = rand.Next(5);
    if (test % 2 != 0)
    return "The service greets you: " + msg;
    else
    throw new FaultException<GreetingFault>(new GreetingFault("A Greeting error occurred. You said: " + msg));
    }

    #endregion
    }
    }

  3. #3
    Join Date
    Sep 2005
    Posts
    2,327

    Re: System.ServiceModel.FaultException Error

    What we need are soap faults that are an industry standard for seamless interoperability, and there is more delivers the answer to Soap Faults as FaultException, which result in a soap fault and do not fault the communication channel.The operations which may throw a FaultException, must be decorated with one or more FaultContract attributes, defining the “exact” FaultException.To test the FaultException concept we defined the following interface:
    [ServiceContract()]

    public interface IFaultDemoService

    {

    [OperationContract]

    [FaultContract(typeof(DivideByZeroException))]

    void FaultDemoFaultSimple();



    [OperationContract]

    [FaultContract(typeof(DivideByZeroException))]

    void FaultDemoFaultException();



    [OperationContract]

    [FaultContract(typeof(DivideByZeroException))]

    void FaultDemoFaultExceptionCodeReason();



    [OperationContract]

    [FaultContract(typeof(DivideByZeroException))]

    void FaultDemoFaultExceptionReason();



    [OperationContract]

    [FaultContract(typeof(DivideByZeroException))]

    void FaultDemoFaultExceptionVerbose();



    [OperationContract]

    [FaultContract(typeof(DivideByZeroException))]

    void FaultDemoException();

    }

  4. #4
    Join Date
    May 2008
    Posts
    816

    Re: System.ServiceModel.FaultException Error

    When you create a new FaultException, you need to supply a reason (either using the string overload or the FaultReason type overload). When you fail to supply the reason, you can receive the following exception:

    The creator of this fault did not specify a Reason.

Similar Threads

  1. Replies: 3
    Last Post: 28-12-2011, 09:15 PM
  2. Replies: 10
    Last Post: 09-09-2011, 10:02 PM
  3. Replies: 6
    Last Post: 23-04-2011, 10:23 PM
  4. Mapping the System.Exception with FaultException
    By sachin.more in forum Software Development
    Replies: 1
    Last Post: 03-06-2010, 11:32 PM
  5. Lsass.exe - system error or Isass.exe - system error
    By CaspaR in forum Windows XP Support
    Replies: 1
    Last Post: 23-11-2004, 03:11 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,929,556.39600 seconds with 17 queries