"cannot serialize interface" error in web service, help please

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • n_o_s_p_a__m

    "cannot serialize interface" error in web service, help please

    My web service has a webmethod whose return type is declared as an
    interface type, for example:

    [WebMethod()]
    public IBusinessProces s GetBusinessProc ess() {}

    which generates the lovely error:

    Cannot serialize interface IBusinessProces s

    The returned object (which implements IBusinessProces s), however, is
    marked Serializable; but I gather that doesn't matter and that this is
    some limitation in web services (because of marshalling)?

    Please let me know what's up here. Thanks in advance.

    -NS
  • Robert Jeppesen

    #2
    Re: "cannot serialize interface" error in web service, help please

    Hi,

    I don't think that you can serialize an interface. Here are some ideas for solving it:
    1. Replace the interface with a base class. Obviously, this won't work if you need to inherit from other classes.
    2. I have no idea if this will work, but:
    Have the webmethod return an object (that implements your interface).
    Make sure that the client app has a reference to the same interface. You probably need to have the interface in a separate dll that
    both client and server has access to.
    In the client, just cast the returned object to your interface.

    --
    Robert Jeppesen
    robert.jeppesen %at%durius-dot-se


    "n_o_s_p_a_ _m" <n_o_s_p_a__m@m ail.com> wrote in message news:1faa8782.0 310080835.4713b 002@posting.goo gle.com...[color=blue]
    > My web service has a webmethod whose return type is declared as an
    > interface type, for example:
    >
    > [WebMethod()]
    > public IBusinessProces s GetBusinessProc ess() {}
    >
    > which generates the lovely error:
    >
    > Cannot serialize interface IBusinessProces s
    >
    > The returned object (which implements IBusinessProces s), however, is
    > marked Serializable; but I gather that doesn't matter and that this is
    > some limitation in web services (because of marshalling)?
    >
    > Please let me know what's up here. Thanks in advance.
    >
    > -NS[/color]


    Comment

    Working...