Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1079851
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T21:56:06+00:00 2026-05-16T21:56:06+00:00

When using WCF together with Enterprise Library 5.0’s validation application block, is it possible

  • 0

When using WCF together with Enterprise Library 5.0’s validation application block, is it possible to customize the error messages which are sent back to the client?

I’ve added the ValidationBehaviour-attribute to my service contract and the FaultContract-attribute to the operation:

<ServiceContract()> _
<ValidationBehavior()> _
Public Interface IContract

    <OperationContract(), FaultContract(GetType(ValidationFault))> _
    Function GetCustomers(ByVal criteria As CustomersSearchCriteria) As List(Of Customer)

End Interface

Then, inside the CustomersSearchCriteria I’ve added the validation attributes:

<Validators.StringLengthValidator(1, 3, ErrorMessage:="here's my error", Tag:="551")> _
Public Property Pin() As String
    Get
        Return _pin
    End Get
    Set(ByVal value As String)
        _pin = value
    End Set
End Property

But when called with invalid parameter, the returned SOAP looks like this:

  <s:Fault>
     <faultcode>s:Client</faultcode>
     <faultstring xml:lang="fi-FI">The creator of this fault did not specify a Reason.</faultstring>
     <detail>
        <ValidationFault xmlns="http://www.microsoft.com/practices/EnterpriseLibrary/2007/01/wcf/validation" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
           <Details xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Practices.EnterpriseLibrary.Validation.Integration.WCF">
              <a:ValidationDetail>
                 <a:Key>Pin</a:Key>
                 <a:Message>The length of the value must fall within the range "1" (Inclusive) - "3" (Inclusive).</a:Message>
                 <a:Tag>criteria</a:Tag>
              </a:ValidationDetail>
           </Details>
        </ValidationFault>
     </detail>
  </s:Fault>

The service returns ValidationFault as it should, but instead of having the error message and tag which I’ve defined, it uses some generic values. Is this a bug or am I doing something wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T21:56:07+00:00Added an answer on May 16, 2026 at 9:56 pm

    I think you need to use the MessageTemplate property instead of the ErrorMessage property. Try:

    <Validators.StringLengthValidatorAttribute(1, 3, MessageTemplate:="here's my error", Tag:="551")> _
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a WCF service that's using Enterprise Library for its Exception Handling and
When using Silverlight together with a WCF Services library how do you solve the
Using WCF RIA Services, how is it possible to determine if a record is
I am using WCF and REST, and I have complex types, which are working
So I'm using WCF WebAPI Preview 6 within my application (Orchard CMS). I'm trying
I am putting together a WCF Data Service for PatientEntities using Entity Framework. My
I have put together a HTTP driven API using the WCF WebAPI that uses
I got a problem on using WCF service and Entity Model with together. I
my application is using WPF for UI, WCF for WebService, EF4 for DataAccess. I
I want to ask if i built my server-client application using WCF technique can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.