Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > Indigo

Defining WCF Fault Messages with a Message Contract

Update your Vista Drivers Update Your Drivers Now!!
 
 
Thread Tools Display Modes
Old 09-26-2007   #1 (permalink)
Chris Mullins [MVP - C#]
Guest


 

Defining WCF Fault Messages with a Message Contract

I've got a WCF application, and i'm trying to get the WSDL just right.

In my contract, I specify a Fault Contract:

[OperationContract]
[FaultContract(typeof(ValidationFault), Name = "ValidationFault")]
Response DoSomething(Request input);

This ValidationFault class is decorated with the standard data contract
attributes. Everything works great, except the WSDL that's generated has
names in it that I can't explicitly set.

<wsdl:fault wsaw:Action="..." name="..."
message="tns:BackgroundCheck_CheckOrderStatus_UnknownIdentifierFault_FaultMessage"
/>

I want to explicity set the message type, so that it's not left as that
ungainly name. This WSDL is going to be with me for a long time to come, and
if I can get it exactly right now, everything will be easier.

I tried creating a MessageContract, and passing that type into the
FaultContractAttribute, but that generates an ugly serialization exception.

Any suggestions of how to explicitly create the FaultMessages?

I'm using Beta2 of Orcas.

(I'm trying hard not to manually write the WSDL file, or to even need to
override the WSDL generation. I would like to do this with as little custom
WCF code as I can...)

--
Chris Mullins



My System SpecsSystem Spec
Old 12-01-2007   #2 (permalink)
Tiago Halm
Guest


 

Re: Defining WCF Fault Messages with a Message Contract

Chris,

Best is to create a Behavior and create the FaultDescription yourself
associating it to every operation available. That way you can control
exactly what is generated (and not automatically concatenated) to the action
and namespace of the fault.

Tiago Halm

"Chris Mullins [MVP - C#]" <cmullins@xxxxxx> wrote in message
news:%23j5oZvGAIHA.4984@xxxxxx
Quote:

> I've got a WCF application, and i'm trying to get the WSDL just right.
>
> In my contract, I specify a Fault Contract:
>
> [OperationContract]
> [FaultContract(typeof(ValidationFault), Name = "ValidationFault")]
> Response DoSomething(Request input);
>
> This ValidationFault class is decorated with the standard data contract
> attributes. Everything works great, except the WSDL that's generated has
> names in it that I can't explicitly set.
>
> <wsdl:fault wsaw:Action="..." name="..."
> message="tns:BackgroundCheck_CheckOrderStatus_UnknownIdentifierFault_FaultMessage"
> />
>
> I want to explicity set the message type, so that it's not left as that
> ungainly name. This WSDL is going to be with me for a long time to come,
> and if I can get it exactly right now, everything will be easier.
>
> I tried creating a MessageContract, and passing that type into the
> FaultContractAttribute, but that generates an ugly serialization
> exception.
>
> Any suggestions of how to explicitly create the FaultMessages?
>
> I'm using Beta2 of Orcas.
>
> (I'm trying hard not to manually write the WSDL file, or to even need to
> override the WSDL generation. I would like to do this with as little
> custom WCF code as I can...)
>
> --
> Chris Mullins
>

My System SpecsSystem Spec
 

Thread Tools
Display Modes




Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51