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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:59:16+00:00 2026-06-12T04:59:16+00:00

I’m writing a WCF webservice and passing in a complex type as a parameter

  • 0

I’m writing a WCF webservice and passing in a complex type as a parameter of the method. The complex type looks like this:

 [DataContract(Namespace = "")]
public class MyRequest 
{
    [DataMember()]
    public string TransactionId { get; set; }

    [DataMember(IsRequired = true)]
    public bool IsRollback { get; set; }

    [DataMember(IsRequired = true)]
    public OrderType OrderType { get; set; }

    [DataMember(IsRequired = true)]
    public ICustomerId CustomerId { get; set; }

    [DataMember()]
    public long OrderId { get; set; }

    [DataMember()]
    public AnotherComplexType PurchaseInfo { get; set; }

The webservice method looks like this:

[ServiceKnownType(typeof(CustomerIdByName))]
[ServiceKnownType(typeof(CustomerIdByAccount))]
public OrderResult Execute(MyRequest order) {
}

The Interface looks like this:

[KnownType(typeof(CustomerIdByAccount))]    
[KnownType(typeof(CustomerIdByName))]
public interface ICustomerId{

string GetId();
}

When I make a request using the SOAP end point, everything works just great. But when passing the request to the REST end point, I get the serialization error.

This is the request I’m using

<MyRequest>
<CustomerId>
<AccountId>59251</AccountId>
</CustomerId>
<IsRollback>false</IsRollback>
<OrderId>0</OrderId>
<OrderType>OrderSubscription</OrderType>
<PurchaseInfo>
<ObjectId>196521</ObjectId>
</PurchaseInfo>
<TransactionId>ABC123</TransactionGuid>
</MyRequest>

Since I had been stuck at this point for too long, I then changed the ICustomerId member to be an abstract class that implements ICustomerId. Again the SOAP end point works fine but sending the request to the rest end point I get an error that states “Cannot create abstract class”

What am I missing or doing wrong here?

Is this failing because the interface is nested in the complex type and not a direct parameter of the webservice method? I’ve used webservices that receive interfaces as parameter and with the KnownType decorators they work just fine. Same question applies to the abstract class, is this not working because the abstract class is nested within a member of the MyRequest complex type?

This is the error message I am getting:

Element CustomerId from namespace cannot have child contents to be deserialized as an object. Please use XmlNode[] to deserialize this pattern of XML

  • 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-12T04:59:17+00:00Added an answer on June 12, 2026 at 4:59 am

    Have you tried decorating your interface as a RESTful method?

    [ServiceContract]
    public interface IMyRequest
    {
        [OperationContract]
        [WebInvoke(
           UriTemplate = "Requests/GetID",
           Method = "POST",
           BodyStyle = WebMessageBodyStyle.Wrapped)]
        string GetId(MyRequest myRequest);
    ...
    

    Also:

    • make sure that the [DataMember] properties match your request payload. Everything that gets passed in your XML request payload must be caught by the serializer in the service. I recommend keeping the naming the same, but you can map it using [DataMember(name=”MyProperty”)]. Also, your [DataContract] must be mapped to match the name of the parent node of your XML payload like [DataContract(Name=”MyRequest”)] but only if the class is named differently than the xml node. Do this, and it will deserialize your xml into the server side object/dto
    • The error you’re getting sounds like it’s complaining about the complex type inside of your DataContract. Your complex type needs to be decorated for serialization the same as your MyRequest type.
    • Also ensure your REST endpoint is bound to webHttpBinding
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace
I have this code to decode numeric html entities to the UTF8 equivalent character.
I am trying to render a haml file in a javascript response like so:

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.