Skip to main content

Webservices and GtkSharp - Mono

Popularity Report

Total Popularity Score: 0

Loading...
Loading...
Loading...
Loading...
Loading...
Loading...

Rank

URL Tag Cloud

Bookmark History

Saved by 1 people (0 private), first by anonymouse user on 2006-07-26


Public Comment

on 2006-07-26 by bgtasoft

Como crear un webservice en .NET (a manubrio)

Public Sticky notes

Writing

Writing web services is not difficult, on the contrary it's a very easy task, you only need to derive from the System.Web.Services.WebService class, set some public methods with their respective attributes and ready. Lets starting writing our web service:

#File: RemoteWebService.cs
//mcs -r:System,System.Web,System.Web.Services RemoteWebService.cs -t:library
using System;
using System.Web;
using System.Web.Services;
 
namespace GtkWebservice
{
	[WebService (Description="Our first web service")]
	public class RemoteWebService : System.Web.Services.WebService
	{
		[WebMethod (Description="Adds two numbers")]
		public int Add (int firstNumber, int secondNumber)
		{
			return firstNumber + secondNumber;
		}
	}
}

We need to set the [WebService ()] attribute in the class for setting that class as the web service class, and we need to set the [WebMethod ()] attribute for setting that method as one web service's method, remember to set as public your web service methods, of course if you want to access then by the "outside world".

Highlighted by bgtasoft

You need to acces the web service from within your Gtk# application, for doing that task you need to get the proxy from that web service, use this:

wsdl http://localhost:8081/index.asmx?wsdl -out:WSAppProxy.cs -n:GtkWebService

for creating the proxy class that allows you to access the public methods from the webservice.

Highlighted by bgtasoft

Readers (1)