By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,724 Members | 859 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,724 IT Pros & Developers. It's quick & easy.

How to expose a class library as web service

P: n/a
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/)

<Id>bmYbXYExgUyonLeg1Ra2Tw==</Id>
Nov 23 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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.
"Miguel Ferreira via .NET 247" wrote:
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/)

<Id>bmYbXYExgUyonLeg1Ra2Tw==</Id>

Nov 23 '05 #2

P: n/a
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

"Miguel Ferreira via .NET 247" <an*******@dotnet247.com> wrote in message
news:O2**************@TK2MSFTNGP15.phx.gbl...
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/)

<Id>bmYbXYExgUyonLeg1Ra2Tw==</Id>


Nov 23 '05 #3

P: n/a
On Fri, 08 Apr 2005 02:08:56 -0700, Miguel Ferreira via .NET 247 wrote:
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.


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
sessions, database or file storage...)
Nov 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.