Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Indigo

Vista - Defining WCF Fault Messages with a Message Contract

 
 
Old 09-26-2007   #1 (permalink)
Chris Mullins [MVP - C#]


 
 

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


 
 

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


Similar Threads
Thread Forum
Fault Message Vista mail
Contract of Friendship Chillout Room
The infamous page fault message Vista performance & maintenance
"Unusual" fault message Vista General


Vista Forums 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 Ltd

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