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 6049561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:35:26+00:00 2026-05-23T07:35:26+00:00

I am developing a web servic e using .NET WCF. I am using a

  • 0

I am developing a web servic e using .NET WCF. I am using a mesaging service style like this:

[ServiceContract]
public interface IMyService {
   [OperationContract]
   MyMessageResponse MyOperation(MyMessageRequest msg);
}

Well, I want to apply the MessageContractAttribute to MyMessageResponse and MyMessageRequest because I need to tune SOAP in my own way.

Well, the problem is that MyMessageResponse and MyMessageRequest are part of a hierarchy (I have many service operations and, so, many message types).

Suppose my hierarchy to be this one (class inheritance pseudocode):

MyMessage <- MyMessageFamily1 <- MyMessageRequest
MyMessage <- MyMessageFamily1 <- MyMessageResponse
MyMessage <- MyMessageFamily2 <- MyOtherMessageRequest
MyMessage <- MyMessageFamily2 <- MyOtherMessageResponse

I would like to apply MessageContractAttribute to MyMessage, then to MyMessageFamily1 and then to MyMessageRequest and to MyMessageResponse (so for the others) like this:

[MessageContract(...)]
public class MyMessage {
   [MessageBodyMember(...)]
   public MyType1 Member1; /* MyType1 has a DataContract applied */
   [MessageBodyMember(...)]
   public MyType2 Member2; /* MyType2 has a DataContract applied */
}

[MessageContract(...)]
public class MyMessageFamily1 : MyMessage {
   [MessageBodyMember(...)]
   public MyType3 MemberFamily11; /* MyType3 has a DataContract applied */
   [MessageBodyMember(...)]
   public MyType3 MemberFamily12; 
}

[MessageContract(...)]
public class MyMessageFamily2 : MyMessage {
   [MessageBodyMember(...)]
   public MyType3 MemberFamily21; /* MyType3 has a DataContract applied */
   [MessageBodyMember(...)]
   public MyType3 MemberFamily22; 
}

[MessageContract(...)]
public class MyMessageRequest : MyMessageFamily1 {
   [MessageBodyMember(...)]
   public MyType4 MemberRequest1; /* MyType4 has a DataContract applied */
   [MessageBodyMember(...)]
   public MyType4 MemberRequest2; 
}

[MessageContract(...)]
public class MyMessageResponse : MyMessageFamily1 {
   [MessageBodyMember(...)]
   public MyType4 MemberResponse1; 
   [MessageBodyMember(...)]
   public MyType4 MemberResponse2; 
}

[MessageContract(...)]
public class MyOtherMessageRequest : MyMessageFamily2 {
   [MessageBodyMember(...)]
   public MyType5 MemberRequest1; /* MyType5 has a DataContract applied */
   [MessageBodyMember(...)]
   public MyType5 MemberRequest2; 
}

[MessageContract(...)]
public class MyOtherMessageResponse : MyMessageFamily2 {
   [MessageBodyMember(...)]
   public MyType5 MemberResponse1; 
   [MessageBodyMember(...)]
   public MyType5 MemberResponse2; 
}

Problem: MessageContractAttribute is an attribute tat can be inherited, but MessageBodyMemberAttribute and MessageHeaderAttribute do not inherit because of their definition.

The problem is that I want to create a service implementing IMyService.
IMyService has MyOperation that uses MyMessageResponse and MyMessageRequest.
But MyMessageResponse should inherit MemberFamily11, MemberFamily12, Member1 and Member2 and treat them in the soap message in order to place these in the body of the soap message. But the MessageBodyMemberAttribute is not inherited…

How can I solve this problem?

  • 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-23T07:35:27+00:00Added an answer on May 23, 2026 at 7:35 am

    You could do that but it is perhaps not the best way to do XML SOAP services because your service definition is being driven by the implementation rather than the other way around. .net and c# are a consequence, not the contract.

    My advice is to create concrete-types and not use derivation or hierarchies. This sort-of problem is easily discovered and rectified in XSD-schema-first SOAP development – 1.

    hope this helps


    1 more information on schema-first can be found here

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

Sidebar

Related Questions

I've been developing a WCF web service using .NET 3.5 with IIS7 and it
I'm developing a web service (in asp.net) and I would like to have each
I'm developing a web-service using WCF, which I want to access using a client
I am developing a web application with Azure Cloude Service and using ASP.NET 3.5,
The background I'm developing a REST API for a C#.NET web application using WCF.
I plan to start developing web-service client using Delphi XE. It looks like creating
I'm actually developing a Web Service in Java using Axis 2. I designed my
I'm going to be developing a REST-ful Web Service for a new public website.
I'm currently developing a WCF REST Web Service that will be running on Microsoft
I am attempting to test a WCF web service I'm developing by accessing it

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.