Web Service Problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello All

I am having issues with a Web Service. The method I am attempting to construct will return a custom object to the caller. This object implements the IPrincipal Interface. One of the methods of the IPrincipal interfact has the method signature o

IIdentity Identity {get;

The problem I am having is that when I attempt so Serialize the object I get the following exceptio

Cannot serialize member CustomObject.IIDentity because it is an interfac

However, If I attempt to chage the above method to a specific object I violate the interfact contract. I have looked on google a lot over the last couple of days but no luck finding anything. Any help would be appreciated. Thanks

Dan
 
Try modifying your serialization pattern slightly. I haven't used Xml
Serialization in awhile so I may be off a little here.

Instead of trying to serialize the IIDentity Member, expose another member
(possibly protected) that is the actual implementation of IIDentity and
serialize that. For example

public class CustomObject
{
private MyIIDentity identity;

[XmlIgnore()]
public IIDentity Identity
{
get { return identity; }
}

[XmlElement()]
protected MyIIDentity MyIIDentity
{
get { return identity; }
set { identity = value; }
}

/* Rest of code */
}



--
Jared Parsons [MSFT]
(e-mail address removed)
This posting is provided "AS IS" with no warranties, and confers no rights.
OR if you wish to include a script sample in your post please add "Use of
included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm"

Dan said:
Hello All,

I am having issues with a Web Service. The method I am attempting to
construct will return a custom object to the caller. This object implements
the IPrincipal Interface. One of the methods of the IPrincipal interfact has
the method signature of
IIdentity Identity {get;}

The problem I am having is that when I attempt so Serialize the object I get the following exception

Cannot serialize member CustomObject.IIDentity because it is an interface

However, If I attempt to chage the above method to a specific object I
violate the interfact contract. I have looked on google a lot over the last
couple of days but no luck finding anything. Any help would be appreciated.
Thanks!
 
Back
Top