1, 新建web service Project
2,新建webservice class
3 webservice client
package com.client;
import java.net.MalformedURLException;
import org.codehaus.xfire.XFireFactory;
import org.codehaus.xfire.client.XFireProxyFactory;
import org.codehaus.xfire.service.Service;
import org.codehaus.xfire.service.binding.ObjectServiceFactory;
import com.webservice.IService;
public class Client {
public static void main(String[] args) {
Service srvcModel = new ObjectServiceFactory().create(IService.class);
XFireProxyFactory factory = new XFireProxyFactory(XFireFactory.newInstance().getXFire());
String helloWorldURL = "http://localhost:8080/WebService/services/Service";
try
{
IService srvc = (IService)factory.create(srvcModel, helloWorldURL);
String result = srvc.example("hello world");
System.out.print(result);
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
}