Re: How to return a user-defined data type object from a webservice?



Yes, I understand that they're different classes and different
objects. That is, after all, the implication of different namespaces.
I also understand that there can be issues around the constructor and
any hidden data, but pragmatically the solution I suggested will
handle the majority of the situations common programmers deal with
between server-side and client-side objects. :-)

Sure, remoting might be a preferable solution to maintain the full,
true object, but sometimes remoting is overkill and I think sometimes
we tend to over-think/over-analyze and ignore simple solutions which
may be less elegant and less pure, but do the job.

Brad.

On Wed, 5 Mar 2008 22:11:52 -0500, "John Saunders [MVP]"
<john.saunders at trizetto.com> wrote:

"Bradley Plett" <plettb@xxxxxxxxxxxxxxxx> wrote in message
news:p28us3pka1v47mj23pg8njg36ldsgok4va@xxxxxxxxxx
What John is saying is all true, but it's a bit of an ivory tower
approach. Sometimes we developers have to bend the rules because it's
the easiest way to get the job done!

Anyway, I'm guessing that you have shared code between your server and
your client (probably using the same class code, shared in VSS). If
that's the case, what you're up against is simply the fact that the
object coming from the server via the web service is in a different
namespace from the object you want to use in your client. There are a
variety of ways of getting around this problem. For example, you can
use reflection and generics to change the namespace of the object in
question. Here's a code sample that will simply copy everything from
one object to another, assuming all their public properties are
identical:

Sorry, Bradley, you're wrong. It's not that the classes are in different
namespaces. They're different classes that happen to have a lot of names in
common. Try returning a custom type that has a non-default constructor, or
methods, or indexers. None of them will show up in the proxy classes because
none of them are described by XML Schema or WSDL.

Remember: they're _proxy_ classes. They are stand-ins for the real classes,
which never leave the server to travel over the wire. They only exist in
order to stand as proxy for the real classes, handling serialization and
deserialization.
.



Relevant Pages

  • Re: Creating multiple namespaces on proxy
    ... I am creating some SOAP web services in .net 2.0. ... classes) on the server side live in different namespaces. ... relationship between the two different request objects on the client ...
    (microsoft.public.dotnet.framework.aspnet.webservices)
  • Frontend Server Routing Mails
    ... address namespaces with a server on other organization (http:// ... Now i want to install a frontend server but maintaining that smtp ... I dont know what will the frontend do with a recipient not found on ...
    (microsoft.public.exchange.admin)
  • using unmanaged namespace in managed code
    ... my unmanaged code. ... C2871: 'server': a namespace with this name does not exist ... How can I use unmanaged namespaces in my managed code? ...
    (microsoft.public.dotnet.languages.vc)
  • Need server OS rebuild advice
    ... predominantly a file and database server that is connected to a SAN. ... Should i unjoin it from the domain, rebuild and then rejoin? ... Complications are that i am using DFS domain namespaces. ...
    (microsoft.public.windows.server.active_directory)
  • RE: DFS
    ... Based on my research, to enable all features in DFS Namespaces, you must ... Servers where namespace management tasks are performed must run Windows ... Clients that access namespaces can run any of the supported client ...
    (microsoft.public.windows.server.sbs)

Loading