一个简单的webservice demo(适合入门)(二)

2014-11-24 07:11:40 · 作者: · 浏览: 1




【web.xml】

[html] view plaincopy
< xml version="1.0" encoding="UTF-8" >
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">


index.jsp





XFireServlet



org.codehaus.xfire.transport.http.XFireConfigurableServlet



0





XFireServlet

/services/*







【客户端项目文件】

y
package com.feihuale.xfire.test;

import org.codehaus.xfire.client.XFireProxyFactory;
import org.codehaus.xfire.service.Service;
import org.codehaus.xfire.service.binding.ObjectServiceFactory;

import com.feihuale.xfire.demo.ITestService;


public class MyClient {

/**
* @param args
*/

public static void main(String[] args) {
try {
Service serviceModel = new ObjectServiceFactory().create(
ITestService.class, "TestService",
"http://com/feihuale/xfire/demo/ITestService", null);

ITestService service = (ITestService) new XFireProxyFactory()
.create(serviceModel,
"http://localhost:8080/TestXFire/services/TestService");

System.out.println("返回值是:" + service.add(5, 8));
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
}

摘自 feihuale的专栏