Using custom classes in webservice

S

stormogulen

Hi!

I'm having some problems figuring out how to organize the different
tiers of an application using a webservice.

The bottom layer is the DAL, and some of the objects in the DAL, I
would like to send via a webservice. That is no problem, just
reference the DAL from the webservice.

Now in the business layer I am calling methods on the webservice,
which return objects of types defined in the DAL. With the exception
that only proxy objects are returned, ie. new classes defined from the
webservice describtion.

This means that I manually have to write code that converts these
proxies to the actual classes, which is very tiresome.

Another option that I have tried is to make the classes in the DAL
implement IXMLSerializable, which has the effect that the webservice
methods now return XMLNodes instead of proxy classes. I can now read
the returned XMLnodes in the DAL classes and reconstruct the objects.

But this also requires a lot of work.

So, does anybody have a better idea how to send objects on a
webservice while retaining the type?

This is a pure dotnet environment, so the consumer should have the
same knowledge as the server.


Best regards,
 
G

GlennDoten

stormogulen said:
Hi!

I'm having some problems figuring out how to organize the different
tiers of an application using a webservice.

The bottom layer is the DAL, and some of the objects in the DAL, I
would like to send via a webservice. That is no problem, just
reference the DAL from the webservice.

Now in the business layer I am calling methods on the webservice,
which return objects of types defined in the DAL. With the exception
that only proxy objects are returned, ie. new classes defined from the
webservice describtion.

This means that I manually have to write code that converts these
proxies to the actual classes, which is very tiresome.

Another option that I have tried is to make the classes in the DAL
implement IXMLSerializable, which has the effect that the webservice
methods now return XMLNodes instead of proxy classes. I can now read
the returned XMLnodes in the DAL classes and reconstruct the objects.

But this also requires a lot of work.

So, does anybody have a better idea how to send objects on a
webservice while retaining the type?

This is a pure dotnet environment, so the consumer should have the
same knowledge as the server.


Best regards,

What I've done a few times is to use the same assembly on the web
service server and client (proxy) sides. On the server side, manually
rip out the proxy classes created when a reference is made to a web
service and changing the generated web service code's namespace to that
of my own classes. That way the same class types are used within the web
service itself and by code that calls those web services. This avoids
what you are bumping into: type proliferation due to web service
auto-generated proxy code.
 
S

stormogulen

What I've done a few times is to use the same assembly on the web
service server and client (proxy) sides. On the server side, manually
rip out the proxy classes created when a reference is made to a web
service and changing the generated web service code's namespace to that
of my own classes. That way the same class types are used within the web
service itself and by code that calls those web services. This avoids
what you are bumping into: type proliferation due to web service
auto-generated proxy code.

Oh! Thank you - that is almost too easy!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top