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

  • Home
  • SEARCH
  • 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 8328211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T01:21:51+00:00 2026-06-09T01:21:51+00:00

The problem is similar to this question: Does WCF FaultException<T> support interop with a

  • 0

The problem is similar to this question: Does WCF FaultException<T> support interop with a Java web service Fault. However, in my case, the custom fault is indeed returned from the service.

Tricky to explain this but here it goes:

From a new WCF client, I’m calling an existing Java web service (that has worked well for years with other kinds of clients). The service XSD defines one custom fault ServiceFault:

<xs:complexType name="ServiceFault">
        <xs:annotation>
            <xs:documentation>On service error</xs:documentation>
        </xs:annotation>
        <xs:all>
            <xs:element name="ErrorCode" type="xs:string"/>
            <xs:element name="ErrorDescription" type="xs:string"/>
        </xs:all>
    </xs:complexType>

This ServiceFault is used for all more specific custom faults (eg. MyMethodFault) so they all get the ErrorCode and ErrorDescription properties, like so:

<xs:element name="MyMethodFault" type="ServiceFault">
    <xs:annotation>
        <xs:documentation>On error in MyMethod</xs:documentation>
    </xs:annotation>
</xs:element>

Next, the WSDL-messages for the faults are defined, like this:

<wsdl:message name="MyMethodFault">
<wsdl:part element="tns:MyMethodFault " name="MyMethodFault">
</wsdl:part>

And finally, the operations are defined with those faults, like this:

<wsdl:fault message="tns:MyMethodFault" name="MyMethodFault">

Looks good to me, so far. And at runtime, the service neatly returns the faults in the detail SOAP-tag, like this:

<ns2:MyMethodFault xmlns:ns2="urn:salessystem:entity:MyService:v1.0">
<ns2:ErrorCode>1000</ns2:ErrorCode>
<ns2:ErrorDescription>TheErrorDescr</ns2:ErrorDescription>
</ns2:MyMethodFault>

However, SvcUtil didn’t generate the more specific custom faults, only the ServiceFault. This is the only mentioning of MyMethodFault in the service reference:

[OperationContractAttribute(Action = "", ReplyAction = "*")]
[FaultContractAttribute(typeof(sale...ServiceFault), Action="", Name="MyMethodFault")]        
[ServiceKnownTypeAttribute(typeof(ServiceFault))]
MyMethodResponse MyMethod(MyMethodRequest1 request);

So, here is the problem:

Since MyMethodFault doesn’t exist I can’t catch FaultException<MyMethodFault>. And furthermore, WCF won’t map a specific fault like MyMethodFault to a ServiceFault at runtime so exceptions of type FaultException<ServiceFault> are never caught. Hence, I never get the error description.

Am I doing something wrong or do I need to tweak the WSDL or the SvcUtil-usage?

Hope anyone can understand the question at all 😛

Thanks,
Björn

  • 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-06-09T01:21:54+00:00Added an answer on June 9, 2026 at 1:21 am

    Sometimes a little vacation is all you need. Problem solved:

    SvcUtil generated not one, but two C# types for the generic custom fault ServiceFault. The other one was located deeper in the namespace hierarchy. And trying to catch that other fault works just fine. All the more specific custom faults (that derive from ServiceFault in the XSD) are caught here and I can see the error code and description of the fault. That’s all I need right now.

    However, I still have no C# types generated for the more specific custom faults such as MyMethodFault described in the XSDs. But maybe I’m not supposed to!

    What I failed to describe in the code examples above is that the specific fault MyMethodFault’s XML in the SOAP response is in inside the Detail-tag of the returned fault:

    <SOAP-ENV:Fault>
      <faultcode>SOAP-ENV:Server</faultcode>
      <faultstring xml:lang="en">ServiceException</faultstring>
      <detail>
        <ns2:MyMethodFault xmlns:ns2="urn:salessystem:entity:MyService:v1.0">
          <ns2:ErrorCode>1000</ns2:ErrorCode>
          <ns2:ErrorDescription>My+Error+Description</ns2:ErrorDescription>
        </ns2:UcsAgreemenFault>
      </detail>
    </SOAP-ENV:Fault>
    

    This fault gets mapped to the “base” ServiceFault in my try/catch. In the SOAP above, you can clearly see the specific fault’s type or name. I don’t know how to get hold of that type/name when the exception is caught, though. All I see is the ErrorCode and ErrorDescription. However, all is well as long as I can catch the ServiceFault and see the code and description.

    Thanks for any thoughts put in to this or any further comments.

    /Björn

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Similar to this question: link However I have already mastered that. My problem is
My problem is very similar to this question , however I am posting a
I have checked this similar question, but the suggestions did not solve my problem:
My problem is extremely similar to the one described in this SO question ,
I have a problem similar to this question which was previously asked but my
I have a similar problem as @Mike in this question . The question is
I'm having a similar problem that is stated in this question: No module named
I asked yersterday this question. Now I am having problem with the similar XML
There is a similar question asked in this post: Does javascript work on mobile
I found this question, which is similar to a problem that I would like

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.