1.  通过IBM网站上的简单例子建立感性认识
应用AXIS开始Web 服务之旅
1.1 Web Service服务端开发
编写Hello.java,内容如下:

public   class  Hello {
 
public  String hello(String name) {
  
if (name == null )
   name 
=   "" ;
  
return   " 你好 " + name + " ,欢迎来到Web服务的世界! " ;
}

}

将文件改名为Hello.jws,并拷贝到AXIS应用目录%AXIS_HOME%\下。
测试该Web服务:打开浏览器并输入http://localhost:8080/axis/Hello.jws ,浏览器显示如下结果:

There is a Web Service here
        
        Click to see the WSDL 

到此我们已经完成了hello的Web服务了,那我们怎么告诉用户如何来使用该服务呢?我们只需要告诉用户我们的Web服务的URL地址: http://localhost:8080/axis/Hello.jws?wsdl 就可以了!下一节我们将介绍如何通过这个地址来访问对应的Web服务。

1.2 Web Service客户端开发
1.2.1 JAVA客户端
使用AXIS的工具将使Web服务的访问和我们之前介绍的创建一个Web服务一样的简单。我们前面安装的AXIS环境中已经包含着这样的工具,它是一个 JAVA类,类名为:org.apache.axis.wsdl.WSDL2Java。打开命令行窗口,转到AXIS目录下的WEB-INF子目录。确保 Tomcat服务已经处于启动状态,键入命令 :

Java -Djava.ext.dirs=lib org.apache.axis.wsdl.WSDL2Java http://localhost:8080/axis/Hello.jws?wsdl

该命令执行的结果是在当前所在目录下产生一个子目录 localhost/axis/Hello_jws,该目录下有四个JAVA源文件,它们分别是:
Hello.java 定义了Web服务接口,此例中只有一个hello方法。
HelloService.java 定义了用于获取Web服务接口的方法。
HelloServiceLocator.java 接口HelloService的具体实现。
HelloSoapBindingStub.java Web服务客户端桩,通过该类与服务器交互。

这四个JAVA类帮我们处理了大部分的逻辑,我们需要的仅仅是把这些类加到我们的项目然后创建一个我们自己的类来调用它们即可。为此我们新加一个类Main.java,为了方便,让这个类与刚产生的四个类都在同一个包下。内容如下:

// Main.java
package  localhost.axis.Hello_jws;
public   class  Main {
    
public   static   void  main(String[] args)  throws  Exception {
        HelloService service 
=   new  HelloServiceLocator();
        Hello hello 
=  service.getHello(); 
        System.out.println(
" Response: " + hello.hello( " 罐头 " )); 
    }

}

使用以下命令进行编译:

javac -classpath lib\axis.jar;lib\jaxrpc.jar localhost\axis\Hello_jws\*.java

如果编译没有问题的话执行该测试程序:

java -Djava.ext.dirs=lib -cp . localhost.axis.Hello_jws.Main//运行结果:Response:你好罐头,欢迎来到Web服务的世界!

在 WSDL2Java工具自动产生的几个类中,类HelloServiceLocator中保存这一些跟服务器相关的信息,例如URL地址等,当服务器的地址更改后但是服务并没有改动的时候直接修改该文件中的字符串定义,而无需重新生成这几个类。具体需要修改的内容,打开该文件便可一目了然。

1.2.2 VC客户端
参见IBM的原贴。

2. Web服务的定义:
A Web service is a software system designed to support interoperable machine-to-machine interaction over a network. It has an interface described in a machine-processable format (specifically WSDL). Other systems interact with the Web service in a manner prescribed by its description using SOAP messages, typically conveyed using HTTP with an XML serialization in conjunction with other Web-related standards.
From:W3C 1.4 What is a Web service?

3. 阅读Axis Developer's Guide(下载的Axis包内/docs/developers-guide.html)
读到一条关于代理上网的信息,或许以后有用,先记一笔。
If you access the internet via a proxy server, you'll need to set an environment variable so that the Axis tests do the same. Set ANT_OPTS to, for example:

-Dhttp.proxyHost=proxy.somewhere.com -Dhttp.proxyPort=80 -Dhttp.nonProxyHosts="localhost"