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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:31:56+00:00 2026-06-08T12:31:56+00:00

I am generating a C# service reference using Visual Studio 2010 from my wsdl.

  • 0

I am generating a C# service reference using Visual Studio 2010 from my wsdl.
(Simplified example, please excuse any syntax errors):

<xs:complexType name="Constraints">
  <xs:sequence>
    <xs:element minOccurs="1" maxOccurs="unbounded" ref="p:Constraint" />
  </xs:sequence>
</xs:complexType>

<xs:element name="Constraint" type="p:ConstraintType" />

<xs:complexType abstract="true" name="ConstraintType />

<xs:complexType name="RelConstraint" >
  <xs:complexContent>
    <xs:extension base="p:ConstraintType">
     ...
    </xs:extension>
  <xs:complexContent>
</xs:complexType>

<xs:complexType name="Logic" abstract="true">
  <xs:complexContent>
    <xs:extension base="p:ConstraintType">
     ...
    </xs:extension>
  <xs:complexContent>
</xs:complexType>  

<xs:complexType name="AndLogic" >
  <xs:complexContent>
    <xs:extension base="p:Logic">
     ...
    </xs:extension>
  <xs:complexContent>
</xs:complexType>

The element of Constraints is .Item not .Constraint (which is fine and I know that this happens with abstraction).

However, Constraints.Item type is RelConstraint not ConstraintType so it doesn’t recognize AndLogic as a possible type.

So it seems that if one concrete type is abstracted one level and another is abstracted two levels the service reference sets any reference to the class only abstracted one level.

(E.g.
ConcreteClassA extends AbstractClassC,
ConcreteClassB extends AbstractClassB which extends AbstractClassC,

ConcreteClassX has element AbstractClassC, which should be of that type.
However, the element is of type ConcreteClassA)

Is there a work around?

This relates to WHY doesn't WCF 'properly' consume/expose abstract types when hosted as a web service

  • 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-08T12:31:59+00:00Added an answer on June 8, 2026 at 12:31 pm

    So my first idea that almost worked was removing the abstract=”true” from the element declaration but leaving it on the type declaration. Here’s the declaration of both the element and type before removing anything:

    <xs:element abstract="true" name="Logic" substitutionGroup="p:Constraint" type="p:LogicType" />
    
    <xs:complexType name="LogicType" abstract="true">
      <xs:complexContent>
        <xs:extension base="p:ConstraintType">
          ...
        </xs:extension>
      <xs:complexContent>
    </xs:complexType>
    

    Visual studio actually generated the code correctly!
    And from what I could find, removing abstract from the element but not the type was not an incorrect implementation of an abstract object. (However, I’m still weary about this point).

    So I wrote up some test xml and sent it to my c# program from my server. And of course… it wouldn’t Serialize the objects correctly (they were all set to null).

    So I finally looked directly at the Reference.cs file to see if I could figure out the problem.

    [System.Xml.Serialization.XmlElementAttribute("Logic", typeof(LogicType), Order = 0)]
    [System.Xml.Serialization.XmlElementAttribute("RelConstraint", typeof(RelConstraintType), Order = 0)]
    public ConstraintComponentType Item
    

    It looked correct but I decided to add XmlElementAttribute declarations for AndLogic and my other logic types to see what happened. And it finally serialized the test data correctly!

    [System.Xml.Serialization.XmlElementAttribute("And", typeof(AndType), Order = 0)]
    [System.Xml.Serialization.XmlElementAttribute("Logic", typeof(LogicType), Order = 0)]
    [System.Xml.Serialization.XmlElementAttribute("RelConstraint", typeof(RelConstraintType), Order = 0)]
    public ConstraintComponentType Item
    

    So what I ended up doing was putting abstract=”true” back on my elements to make my schema correct, and then going in and doing the aforementioned step along with changing anywhere it incorrectly generated the type, e.g.

    [System.Xml.Serialization.XmlElementAttribute("Logic", typeof(LogicType), Order = 0)]
    [System.Xml.Serialization.XmlElementAttribute("RelConstraint", typeof(RelConstraintType), Order = 0)]
    public RelConstraintType Item
    

    So the only problem is that if you want to regenerate the service reference, you have to go back through and manually edit the Reference.cs file again.

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

Sidebar

Related Questions

Visual Studio 2010, .Net 4.0 I'm generating some Domain Service Classes and this is
I am using Silverlight 4, in Visual Studio 2010. I have some Domain Services
I'm generating json from a Rails app, and am filtering fields using the format.json
I am adding a WCF Service Reference in a Silverlight project, it is generating
I am consuming a SOAP web service using php5's soap extension. The service' wsdl
I've written a JAX-WS webservice in Java by generating a WSDL and classes from
Is there any way to consume a SOAP based Spring web service without generating
I'm generating a reporting services report from an ASP.NET (MVC) based application but am
Generating normal columnar data in excel file is quite easy but does any one
When generating models from postgresql with ColdFusion Illudium Code generator the boolean values get

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.