Eclipse+Axis使用WSDL文件生成Web Service服务端/客户端

JDK版本:1.5.0_22java

Eclipse版本:Helios Service Release 2(3.6.2)ios

WSDL文件的建立过程见http://blog.csdn.net/a19881029/article/details/24625429web

建立一个名字为math的Java web工程,并将WSDL文件拷入该工程中服务器

将Axis所需的jar包拷贝至WebRoot\WEB-INF\lib目录下,这些jar包会自动导入math工程中.net

一,生成Web Service服务端code

选中MathImpl.wsdl文件右键->Web Services->Generate Java Bean Skeletonblog

仅仅生成Web Service服务端代码便可,服务器选择Tomcat 6.0,Web Service环境选择Apache Axis,服务工程选择math工程,选择完成后点击“下一步”:ip

 而后选择Web Servic服务端代码的生成路径,选择完成后点击“下一步”:部署

只生成Web Service服务端代码,并不进行部署,这里直接点击“完成”便可get

此时能够发如今math工程中自动生成了Web Service服务端的代码和部署/解除文件

只需编写MathImplSoapBindingImpl文件中的服务端具体处理过程便可:

/**
 * MathImplSoapBindingImpl.java
 *
 * This file was auto-generated from WSDL
 * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter.
 */

package com.sean.ws;

public class MathImplSoapBindingImpl implements com.sean.ws.MathImpl{
    public int plus(int a, int b) throws java.rmi.RemoteException {
        //return -3;
    	int c = a + b;
    	System.out.println("The result is:" + c);
    	return c;
    }
}

 

二,生成Web Service客户端

选中MathImpl.wsdl文件右键->Web Services->Generate Client

 只生成Web Service客户端代码,选择完成后点击“下一步”:

而后选择Web Servic客户端代码的生成路径,选择完成后点击“完成”:

此时能够发如今math工程中自动生成了Web Service客户端代码

直接使用MathImplProxy类便可:

package com.sean.ws;

import java.rmi.RemoteException;

public class Test {
	public static void main(String[] args) throws RemoteException {
		MathImplProxy proxy = new MathImplProxy();
		proxy.plus(1, 2);
	}
}
相关文章
相关标签/搜索