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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:06:14+00:00 2026-06-05T04:06:14+00:00

I created some data classes inside of my WCF service to transport data back

  • 0

I created some data classes inside of my WCF service to transport data back and forth between the service and the client. As such, these “objects” are decorated with [ServiceContract] and [DataMember] thus exposed to the client so that I can instantiate one, fill it in and send it off to the service. Now, I noticed that I can use polymorphism within the service, but I’m not having so much luck doing it between the client and the service. For instance

In the service, there is a class called Ticket and a class called MOCTicket that derives from Ticket. There is also a method that accepts Ticket as an argument. Normally, I should be able to send that method an MOCTicket object and it’ll work fine since it derives from Ticket, and I can do this within the service. However, if I instantiate an MOCTicket object on the CLIENT side and try to send it to the service method that accepts Ticket, it throws errors. I’m guessing this is a serialization issue.

I’m just kind of confused about sort of behaviors I can get out these data classes. You get some but not others. Like I can’t serialize behaviors/methods or constructors, but I can serialize a lazy loaded property (or so it would seem). At any rate, if someone could help me out with achieving what I described above or if it’s possible. Any additional clarification about these “objects” would be appreciated as well. I’ve googled around trying to find answers, but couldn’t find anything written clear enough to answer this. Thanks.

  • 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-05T04:06:16+00:00Added an answer on June 5, 2026 at 4:06 am

    I think I found what I’m looking for, at least at this stage. By adding additional decorations to the service method, I can tell the serializer what types to expect:

    [ServiceContract]
    public interface IService1
    {
        [OperationContract]
        [ServiceKnownType(typeof(SvcBaseTicket))]
        [ServiceKnownType(typeof(SvcMOCTicket))]
        bool DoStuff(SvcBaseTicket user);
    }
    

    And then call like this will work:

    using(var client = new MyClient())
    {
       var ticket = new SvcMOCTicket();
       if(client.DoStuff(ticket))
       {
          //do things
       }
    }
    

    I tested to ensure that the service class returning a “base class” type that was actually a derived class in disguised was coming back with all of the additional properties, and it did indeed. Along with a new property called “ExtensionData”. Wunderbar.

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

Sidebar

Related Questions

I have created a web service which returns some data and am trying to
I have created a web service which is saving some data into to db.
I have created data sources from my objects in my project, some of which
I've created some classes that will be used to provide data to stored procedures
I have created some enums as .dll dynamically using data from database. I am
I have some data (which users input using WYSIWYG editor). I have created a
I have created an app in android and it requires some data to be
I just created a PHP page that spits outs some data from my database
We have created a custom dataset and populating it with some data. Before adding
I created a web control, and it needs some data from its parent page.

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.