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!
Re: I Wrote a Web Service :)
I know, I know. I know how to do it. I have watched others set it up and make it work.
It's just that I was never so motivated to want to try it myself. Now that you mentioned it, I did what you said, and everything did work.
I do have to say this: with Axis, there is not the sense of excitement. It's like, Web Services? we can do that. Just understand these 25 concepts, change the file extension and throw it over the fence, whatever.
Mono's XSP, on the other hand, is something new and ground breaking. It's really simple to get your first Web Service going. For a comparable experience in Java, I have to go back all the way to the Applet days. Remember your first Applet? Remember appletviewer? It's kind of like that.
Applet may be out of fasion now. But I believe it is the Applet experience that got Java where it is now.
I just had a similar experience with Mono and XSP. That's about all I have to say about that.
Re: I Wrote a Web Service :)
Re: I Wrote a Web Service :)
Public Services "R" Us!
The "[WebMethod()]" is an attribute that makes the method a Web Service. JDK 1.5 will support something similar through JSR 175. We call them annotations.
The "-r:System.Web.Services" switch tells the C# compiler to link against the System.Web.Services.dll. It's similar to the "-l" switch of gcc. By default the Mono C# compiler only compiles and links against a finite subset of the dll's shipped with it.