G
Guest
This is a definite and reproduceable bug in Web Services, Visual Studio 2003.
Here is a simple example. Create a web service...
// this represents an original version of an object
class ObjectV1 { ... } // holds some arbitrary data
// this represents a newer version with extra information
class ObjectV2 : ObjectV1 { ... } // adds some additional information
// this is an 'original' function, which returns the base class original
information
[WebMethod]
public ObjectV1 _GetObject()
{
// this represents the base layer was updated with a new derived
// object with extended information.
return new ObjectV2();
}
// this is a stub function to return the new version explicitly
[WebMethod]
public ObjectV2 _GetObject2()
{
// very simple upcast knowing the base layer is updated
// no need to reimplement everything redundantly for this new type
return _GetObject() as ObjectV2;
}
Create a web service client... Everything WORKS...
But now... following the same extensibility model...
Extend the web service to return ObjectV3...
class ObjectV3 : ObjectV2 { ... } // latest extended version
// this represents the base layer is returning the latest object version
// through the otherwise non-changing public layer
[WebMethod]
public ObjectV1 _GetObject()
{
return new ObjectV3();
}
Now, at this point, the client is still using _GetObject operating on
ObjectV1.
WITHOUT REGENERATING THE WEB SERVICE ON THE CLIENT SIDE...
The client crashes with an error parsing the XML response. Why? ObjectV3 is
polymorphically compatible with ObjectV2. The call signature of _GetObject
hasn't changed. It is still legal usage of polymorphism. There wasn't a
problem with it when it was V2->V1.
You will actually see the problem simply going from V1 to V2, provided you
do not regenerate the WSDL on the client side.
Why not regenerate the client's web service definition?
This represents extending a web service while still supporting previous
versions of the web service clients, who retrieve a polymorphic downcast of a
derived type, i.e. operate on an inherited type from its base class. They are
installed, and need to continue functioning.
Why can't the XML be parsed without regenerating the web client's web
service definition?
You're wrong if you think it SHOULD be this way. Also, don't suggest using
an alternate extensibility model. This model was not my idea, but in itself,
it is very reasonable, and it is probably very common. I already know how to
resolve it by rearchitecturing the web service to promote extensibility...
Boxing and unboxing the parameters and return object with version control.
I am basically looking for a resolution that doesn't require redundant
reimplementation and maintanence of several versions of code.
Here is a simple example. Create a web service...
// this represents an original version of an object
class ObjectV1 { ... } // holds some arbitrary data
// this represents a newer version with extra information
class ObjectV2 : ObjectV1 { ... } // adds some additional information
// this is an 'original' function, which returns the base class original
information
[WebMethod]
public ObjectV1 _GetObject()
{
// this represents the base layer was updated with a new derived
// object with extended information.
return new ObjectV2();
}
// this is a stub function to return the new version explicitly
[WebMethod]
public ObjectV2 _GetObject2()
{
// very simple upcast knowing the base layer is updated
// no need to reimplement everything redundantly for this new type
return _GetObject() as ObjectV2;
}
Create a web service client... Everything WORKS...
But now... following the same extensibility model...
Extend the web service to return ObjectV3...
class ObjectV3 : ObjectV2 { ... } // latest extended version
// this represents the base layer is returning the latest object version
// through the otherwise non-changing public layer
[WebMethod]
public ObjectV1 _GetObject()
{
return new ObjectV3();
}
Now, at this point, the client is still using _GetObject operating on
ObjectV1.
WITHOUT REGENERATING THE WEB SERVICE ON THE CLIENT SIDE...
The client crashes with an error parsing the XML response. Why? ObjectV3 is
polymorphically compatible with ObjectV2. The call signature of _GetObject
hasn't changed. It is still legal usage of polymorphism. There wasn't a
problem with it when it was V2->V1.
You will actually see the problem simply going from V1 to V2, provided you
do not regenerate the WSDL on the client side.
Why not regenerate the client's web service definition?
This represents extending a web service while still supporting previous
versions of the web service clients, who retrieve a polymorphic downcast of a
derived type, i.e. operate on an inherited type from its base class. They are
installed, and need to continue functioning.
Why can't the XML be parsed without regenerating the web client's web
service definition?
You're wrong if you think it SHOULD be this way. Also, don't suggest using
an alternate extensibility model. This model was not my idea, but in itself,
it is very reasonable, and it is probably very common. I already know how to
resolve it by rearchitecturing the web service to promote extensibility...
Boxing and unboxing the parameters and return object with version control.
I am basically looking for a resolution that doesn't require redundant
reimplementation and maintanence of several versions of code.