473,396 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to expose a class library as web service

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
3 6279
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: David | last post by:
Hello. Can anybody show me how can I expose method from my Windows Service application?
2
by: maxim | last post by:
Hi, I have a Class in C# that exposes property from System.Uri type. I want to access this property from classic Visual Basic. public class TestClass {
1
by: C | last post by:
Hi, I have a class withing my ASP.Net project which I want other applications to use so I am going to create a separate Assembly for this. In addition to this I want to know if it is possible...
4
by: Don | last post by:
It is possible to expose an enumerated type from within a class library so that other projects referencing that class library will see it in the class's namespace? For example, if I have a class...
6
by: cipher | last post by:
I have some constant values in my web service that my client application will require. Having to keep server side and client side definitions insync is tedious. I am trying to do something like...
0
by: russell.lane | last post by:
I have a web service that exposes database contents as disconnected datasets. I would to use that web service from within a class library. I have included a web reference to the service in my...
1
by: MisterT | last post by:
Hello, I have a web service that updates an SQL database thru a web service. I would like to expose the database table so I can easily add it as a Data Source in VS 2005 to program the web...
0
by: kostadin | last post by:
I want to expose the whole functionality of a library through a web service. In order to do that of course I've created web methods for all public methods in this library. Because only public data...
5
by: =?Utf-8?B?TWFuaQ==?= | last post by:
Hi, I have a webservice which uses a c# Dll,This Dll is a C# class library which contain few class . I am able to see the class when in the Web service but when i create a stubb class of the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.