<< May 7, 2004 | Home | May 9, 2004 >>

I Wrote a Web Service :)

I have never written a Web ServiceTM. Until today, that is.

I've heard all about Axis, WSDL, SOAP, doc/literal, rpc/encoded, JAX-RPC, SAAJ, etc. But the process of setting everything up and actually writing and testing a Web Service in Java just seemed so daunting. And I never got around to try it.

The Beta 1 release of Mono contains a ASP.NET/Web Services host called XSP. So I decided to take it for a spin.

[weiqi@gao] $ cat hello.asmx
<%@ WebService Language="C#" Class="Hello" %>
using System;
using System.Web.Services;
 
public class Hello : WebService {
    [WebMethod()]
    public string SayHello() {
        return "Hello, World!";
    }
}

[weiqi@gao] $ mono /usr/bin/xsp.exe
Listening on port: 8080
Listening on address: 0.0.0.0
Root directory: /home/weiqi/temp/src/webservice
Hit Return to stop the server

The URL http://localhost:8080/hello.asmx gives me the WSDL and client proxy code. I took the client code, added a Main() method, compiled, and run it. It worked as expected.

[weiqi@gao] $ mcs -r:System.Web.Services hello.cs
Compilation succeeded
[weiqi@gao] $ mono hello.exe
Hello, World!