How - Convert Classe/DLL to Web Service?

Z

Zean Smith

I wrote an ASPX web application and a C# Classes which compiled as a
seperated DLLs. In my ASPX web app. I import that DLL as Reference.

How do I convert those Classes to Web Services? is it easy? so that other
ASPX web app can reuse my classes over the network. Is this possible? or do
I have to rewrite the classes?

Thanks a lot
 
G

Guest

Its not that easy.. that's not really what a WebService is for.. it's usually
an entirely different animal.
Anyway, are all these sites on the same server? Put the DLL's in the GAC
perhaps, otherwise just add the reference to the other sites.
 
D

David Browne

Zean Smith said:
I wrote an ASPX web application and a C# Classes which compiled as a
seperated DLLs. In my ASPX web app. I import that DLL as Reference.

How do I convert those Classes to Web Services? is it easy? so that other
ASPX web app can reuse my classes over the network. Is this possible? or
do I have to rewrite the classes?

Sure it's very easy. Just add a ASMX web service class to your project and
expose methods which use your DLL.

http://support.microsoft.com/default.aspx?scid=kb;en-us;308359
http://samples.gotdotnet.com/quickstart/aspplus/doc/webservicesintro.aspx


You don't expose the classes directly; if that's what you need then you'll
need to share the assembly.

David
 
K

Kevin Spencer

How do I convert those Classes to Web Services? is it easy? so that other
ASPX web app can reuse my classes over the network. Is this possible? or
do I have to rewrite the classes?

You don't convert the classes. You write a web service that has web service
methods that talk to the class and send responses to the client. The
trickiest part is how you expose the classes (if necessary) to the web
client. Any data returned by a web service method must be serializable as
XML. That includes primitives, and classes. Primitives serialize
automatically, as do some CLR classes, such as DataSet, DataTable, and some
Collections. If you create custom classes, only parts of them can be
automatically serialized. Public primitive fields are automatically
serialized. Methods are not. In some cases, you may want or need to create a
custom XML Serializer for your class. However, be aware that unless there is
a corresponding XML desrializer on the other end, it may not be useful to do
so. Creating custom XML serializers and de-serializers is a bit more
advanced, but as of yet I haven't had to in any of my web services projects.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.
 

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

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top