views:

558

answers:

2

I am writing a .NET webservice (VB.NET). One of the methods DisplayChild() returns an object of type Child. Child is defined:

<Serializable()> _
Public Class Child
    Inherits BaseClass
    Property NotInInheritedProperties() as Object
    ...
    End Property
End Class

and the BaseClass looks something like:

<Serializable()> _
Public MustInherit Class BaseClass

    Property BaseProperty() as Object
    ...
    End Property
End Class

However, in the SOAP definition that shows the return from the DisplayChild() the only property shown in the output is the NotInInheritedProperties property. My question then, is how do I get the properties in the BaseClass to show up in the SOAP document? Originally I didn't have the Serializable attribute on the BaseClass thinking that was the problem. However, even after changing that it still didn't work.

+1  A: 

Even if BaseProperty isn't on displayed on the SOAP Definition when you view the service via your web browser, it looks like it's still part of the WSDL. If you review the WSDL (YourService.asmx?WSDL, or that link that says "Service Description" on YourService.asmx), you should see the inheritance between BaseClass and Child, something like:

<s:complexType name="Child">
  <s:complexContent mixed="false">
    <s:extension base="tns:BaseClass">
      <s:sequence>
        <s:element minOccurs="0" maxOccurs="1" name="NotInInheritedProperties" />
      </s:sequence>
    </s:extension>
  </s:complexContent>
</s:complexType>
<s:complexType name="BaseClass" abstract="true">
  <s:sequence>
    <s:element minOccurs="0" maxOccurs="1" name="BaseProperty" />
  </s:sequence>
</s:complexType>

If you have a consumer of your web service that can't see that property, then it may be an issue with their specific implementation (I've worked with some "web service enabled" enterprise apps that absolutely choked on web services that return complex types)

Jeremy Frey
Yes, the properties are available in the WSDL. I had heard the term but never read one. I guess when you have a web reference and you update it, that it is looking at the WSDL to get the information which shows up in the object browser. Always wondered how that worked.
Anthony Potts
A: 

I ended up posting this question again somewhere else, and found an answer several weeks later: http://stackoverflow.com/questions/1875642/inherited-properties-do-not-appear-in-soap-sample-on-asmx-file

Grinn