Generating the Web Service code from C# class.

  • Thread starter Jean-Francois Hamelin
  • Start date
J

Jean-Francois Hamelin

Hi,

I have a C# class and I have to expose it through a Web Service, but I don't
want to write the Web Service, is there a generator that can produce the
..asmx file based on my .cs file?

Thanks
JF
 
M

[MSFT]

Hi Jean,

Not sure if there is wsuch one. Maybe you can search with google or in
www.gotdotnet.com.

Anyway, I don't think it is very difficut to create such a web service. For
example, you can add such a function first:

public MyClass MyClassFactory()
{
...
}

This class will generate a object from your class. Then create a web method
like:

[WebMethod]
public MyClass WebClass()
{
return MyClassFactory();

}

For a web service, we need to create the virtual folder and consider
deployment issues. Therefore, I prefer doing it myself instead of some
third party tools. Do you think so?


Luke
 
J

Jean-Francois Hamelin

Thanks for the reply, I was looking more for a complete wrapping of my
class, but I like the idea of using a factory pattern. My concern is I want
to maintain my class and not the web service interface, which I can achieve
by using the factory pattern, here I write the factory only once.

Thanks
JF
 
M

[MSFT]

If you have only one or two class, you can just factory code once. If you
need to work with multiple code, I think you can add a parameters to the
Factory class, to specify the class you wan to create. This also require we
change the code for each of class. Anyway, the change is very little.

Luke
 

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

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top