使用xfire做个简单的webservice
闲话不说,直接上。(对于xfire的介绍等的东西,见百度或谷歌)
1、下载xfire。地址: http://xfire.codehaus.org/Download?
????? xfire-distribution-1.2.6.zip
????? xfire-all-1.2.6.jar
2、新建j2ee项目。导入jar包
?
????
?
3、在web.xml中配置xfire的servlet
?
?6、启动taomcat。使用浏览器打开http://localhost:8080/myxfire/services/
????
?
?
??? 如果这一步报错:
??? class path resource [META-INF/xfire/services.xml] cannot be opened because it does not exist
??? 则需要将META-INF文件夹拷到WEB-INF文件夹下,如下图:
???
?
?
7、调用webservice
?
public static void main(String[] args) {String url = "http://localhost:8080/myxfire/services/HelloService?wsdl";try {Client client = new Client(new URL(url));Object [] obj = client.invoke("sayHello",new Object[]{});System.out.println(obj[0]);} catch (MalformedURLException e) {// TODO Auto-generated catch blocke.printStackTrace();} catch (Exception e) {// TODO Auto-generated catch blocke.printStackTrace();}}?