I have a Web service that has a method returning a class, so complex
type.
This class is serializable. It works just fine.
I created a secoind method that returns a class derived from the first
one.
The SOAP response lists only the extra fields I added. The fields from
the
base class are not shown. I would like to have all fields included in
the
SOAP response. What should I do ?
Josh Twist - 02 Feb 2006 08:22 GMT
WSDLs have inheritence too (from XSD) so normally, inherited classes
should work just fine, but only the extra fields in the complex type
are displayed.
if you have two classes ClassA and ClassB where ClassB inherits ClassA
- you'd expect to see something like this in the WSDL:
<s:complexType name="ClassB">
<s:extension base="s0:ClassA">
<s:sequence>
<!-- the additional properties added by ClassB go here -->
</s:sequence>
</s:extension>
</s:complexType>
The s:extension node is essentially inheritence - says this class (B)
extends class A.
Does that help? Have you tried your service? Are you sure that
something is wrong?
Richard Purchas - 16 Feb 2006 12:42 GMT
XML serialization has problems such as this (and other issues, such as not
serializing private fields etc.). One option is to binary serialize the
custom class and pass as array of byte. This has worked well for me, and
also suppresses generation of proxies for the complex types as well.
>I have a Web service that has a method returning a class, so complex
> type.
[quoted text clipped - 7 lines]
> the
> SOAP response. What should I do ?
Josh Twist - 16 Feb 2006 13:20 GMT
Hi Richard,
Your suggestion kind of defeats the points of Web Services - self
description, interoperability. A client using such a service (with
binary serialization) isn't going to understand anything about your
service from the WSDL and has to be written in .NET.
You might as well use Enterprise services or (dare I say it) Remoting
and avoid the overhead of asmx.
Josh
http://www.thejoyofcode.com/
Richard Purchas - 27 Feb 2006 13:18 GMT
I see your point and agree whole-heartedly, but understand where my comments
came from:
Firstly, the web services I am talking about are used only for internal
purposes. I have a project with dozens of business classes that are passed
to these internal web services. If a Developer uses the out-of-box tools to
create a reference to our web services then they end-up with dozens of
proxies created in my consuming projects, which is a really undesirable
situation to be in.
Additionally, stand XML serialisation simply didn't cut the mustard; private
fields aren't serialised etc.
What alternatives can you offer to get around these two issues (whilst still
permitting use of the tools I refer to) ?
> Hi Richard,
>
[quoted text clipped - 8 lines]
> Josh
> http://www.thejoyofcode.com/