XFire is a next-generation java SOAP framework. XFire makes service oriented development approachable through its easy to use API and support for standards. It is also highly performant since it is built on a low memory StAX based model.
Quick Start
1. download and unzip xfire-all-1.0-M6a.zip
2. cd examples/book
3. maven war
小插曲1: 安装Maven(第一次使用, 解压后将bin目录增加进PATH即可), maven 2.0不兼容1.x(没进一步了解), 某些jar下载不到时, 将jar放进maven Repository(估计有方法disable download的)
4. deploy xfire-demo.war to Tomcat
Access the WSDL via: http://localhost:8080/xfire-demo/services/BookService?wsdl
创建SOAP客户端
小插曲2: test case并没有client测试程序(XFire找不到相关Util Class), 对于Hello World程序, copy paste是首选方法, wuyu的接触xfire使用vs2005的J#, 自由的天空的web service 实践(1)使用C#, 似乎使用MS的技术创建SOAP客户端更简单, 刘冬的应用AXIS开始Web 服务之旅(Java的, 可以参考)
1. use WSDL2Java
Java -Djava.ext.dirs=lib org.apache.axis.wsdl.WSDL2Java http://localhost:8080/xfire-demo/services/BookService?wsdl
2. BookCilentTest.java
1package org.codehaus.xfire;
2
3import org.codehaus.xfire.BookService.BookServiceLocator;
4import org.codehaus.xfire.BookService.BookService;
5import org.codehaus.xfire.BookService.BookServicePortType;
6import org.codehaus.xfire.demo.Book;
7
8public class BookCilentTest {
9 public static void main(String[] args) throws Exception{
10 BookService service = new BookServiceLocator();
11 BookServicePortType serviceType = service.getBookServiceHttpPort();
12 Book[] books = serviceType.getBooks();
13
14 for (int i = 0; i < books.length; i ++)
15 {
16 Book book = (Book) books[i];
17 System.out.println("title:" + book.getTitle());
18 System.out.println("isbn:" + book.getIsbn());
19 System.out.println("author:" + book.getAuthor());
20 System.out.println("");
21 }
22 }
23}