Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 18-05-2009
Member
 
Join Date: May 2009
Posts: 533
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 ?
Reply With Quote
  #2  
Old 18-05-2009
Member
 
Join Date: Apr 2008
Posts: 2,563
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.

Quote:
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
}
}
Reply With Quote
  #3  
Old 18-05-2009
Member
 
Join Date: Sep 2005
Posts: 2,321
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:
Quote:
[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();

}
Reply With Quote
  #4  
Old 18-05-2009
Member
 
Join Date: May 2008
Posts: 804
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.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "System.ServiceModel.FaultException Error"
Thread Thread Starter Forum Replies Last Post
Error ?System restore failed? and ?Not enough disk space to perform system recovery" in Dell Inspiron 1545 Chitti's Portable Devices 3 28-12-2011 09:15 PM
System crashed with driver power state failure error in Puget serenity system KumaraVel Operating Systems 10 09-09-2011 10:02 PM
?This installation is forbidden by system policy. contact your system administrator? Error message while installing the Corel Video Studio X3. Jaiya Windows Software 6 23-04-2011 10:23 PM
Mapping the System.Exception with FaultException sachin.more Software Development 1 03-06-2010 11:32 PM
Lsass.exe - system error or Isass.exe - system error CaspaR Windows XP Support 1 23-11-2004 03:11 AM


All times are GMT +5.5. The time now is 07:55 PM.