all groups > dotnet web services > april 2005 >
You're in the

dotnet web services

group:

How to expose a class library as web service



Re: How to expose a class library as web service William Stacey [MVP]
4/8/2005 12:00:00 AM
dotnet web services: And normally what I do is create your library as normal without any web
specific stuff. Then create web class to "surface" only the needed function
from your library or libraries (I think facade pattern.) That way, you can
surface Web, WSE, or Indigo versions of your interfaces and your base class
libraries stay the same with no knowlege of how they get called. And you
have a clear seperation.

--
William Stacey, MVP
http://mvp.support.microsoft.com

[quoted text, click to view]
How to expose a class library as web service Miguel Ferreira via .NET 247
4/8/2005 2:08:56 AM
Hi !

I have developed a class Library with several classes and methods. Its working fine with a windows forms test application, but now i need to create a webservice that will expose those methods.

Do i have to create a method signature replica to all interfaces and methods, that will consume the internal class library, like this:

<WebMethod()> _
Public Function Method1() As TypeDefinedInClassLibrary
'Call Method1 in class library
'Return value returned by Method1 on class library
End function

Or is there any way to expose all public methods from class library in a more simple way, like saying to the webservice to use and expose the class library ?

Thanks a lot for your help
Miguel Ferreira
--------------------------------
From: Miguel Ferreira

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

RE: How to expose a class library as web service Ravichandran J.V.
4/8/2005 7:51:12 AM
Your class must inherit from the base System.Web.Services.WebService class
for it to be a web service and yes, all the methods that you want to expose
in in the class must be marked with the WebMethod attribute.

with regards,

J.V.


[quoted text, click to view]
Re: How to expose a class library as web service Mehdi
4/11/2005 12:00:00 AM
[quoted text, click to view]

And to complete the other answers, don't forget that web services are
stateless by defenition. So if you libaray classes need to persist a state
between method invocations, you'll have to do it manually (by using
AddThis Social Bookmark Button