Web services Re-mystified
Every tutorial on web services I’ve found talks about WSDL that and SOAP and XML and blah blah blah. Who cares? Just think of a web service as magic and ignore it (RPC over magic works). You don’t care about the details, you just want the benefits. I feel your pain – here’s how to make a functional web service without any of the crap. I assume you’re using Visual Studio 2003 on XP with .Net 1.1 – I expect you to use the pro tools.
First, fire up VS and go to new project, C# web service. Give it a name.

Click “click here to switch to code view”. Type in this bit of code:

If you want to copy/paste, here:
[WebMethod]
public
int add(int a, int b)
{
return
a+b;
}
Now, the hard part: hit control-f5. You should see something like:

Yay. Now, copy the URL into a buffer and go to file->close solution. Here’s the URL in case you forget it: http://localhost/Duh/Service1.asmx . Now, within VS hit control-shift-N. Pick Visual C# Console app, and call it whocares.

Go to the references section and right click. Choose “add web reference”.

Paste in the URL, click GO, and click add reference. 1, 2, 3. Easy.

Now go the the main bit and replace it with:
[STAThread]
static
void
{
localhost.Service1 sum = new localhost.Service1();
Console.WriteLine(sum.add(1,2).ToString());
}
It’s much cooler
if you type it in so you can see the IDE helping you. Now hit Control-F5 and
you’ll see:

That’s it. It works. You don’t need to know the rest.
Love,
Ry
PS: If you really care, here are the buzzwords you need to know: XML SOAP WSDL sample tutorial webservice. You’re now buzzword compliant.
PPS: I used a command line sample to show how easy this is for the client – you don’t need a bunch of web pages and vbscript.