I am trying to use WSE2 SP2 to call some SoapMethods over tcp.
Everything works great.  Except on my SoapService class I have a method:

[SoapMethod(GetMessage)]
public BaseMessage GetMessage(Guid clientid)

this method is to return a message waiting for a particular client.  All
of the different message types are derived from BaseMessage. For example
PingMessage which is returned every 15 seconds if there are no other
messages waiting for the client.

We return a message along the lines of:

BaseMessage bm = new PingMessage();
return bm;


On the client side this is the code that receives: 

SoapEnvelope envelope = base.EndSendRequestResponse(iar);
BaseMessage bm =
(BaseMessage)envelope.GetBodyObject(typeof(BaseMessage));

I get an InvalidOperationException " There is an error in XML document
(1, 2)."

This is the xml that the server passes back to the client in the soap
envelope body:

<PingMessage xmlns:xsd="http://www.w3.org/2001/XMLSchema";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xmlns="http://tempuri.org/";>
        <MessageType>Ping</MessageType>
</PingMessage>

I would expect something more along the lines of:

<BaseMessage xsi:type="PingMessage">
        <MessageType>Ping</MessageType>
</BaseMessage>


I have tried adding something like:

[XmlInclude(typeof(PingMessage))]
public class BaseMessage...

This does not help anything, in fact the serialization happens the same
way with or without that attribute, and I would prefer not to use that
attribute because I would like systems using this MessagingServer object
to be able to pass their own messages derived from BaseMessage without
having to edit the code.

This of course is a simplified example and most messages will carry
quite a bit more data.

I have been working on this for almost a whole day and it is driving me
nuts!  If anyone can shed some light on my issue or point me in a
direction or perhaps a better way to achieve my objective of simply
passing objects between clients and server I would be forever grateful.

Joshua Perry

===================================
This list is hosted by DevelopMentor�  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to