1、新建web service project
选中xfire,下载xfire的包导入
2、写一个接口
3、写一个实现类
4、新建一个web service client 测试类
在main中加入
String serviceURL = "http://localhost:808/webserviceDemo/services/sayHi" ;
//此处的URL为WSDL所在URL
Service serviceModel = new ObjectServiceFactory().
create(SayHiService.class,
null,
"http://localhost:808/webserviceDemo/services/sayHi?wsdl", null) ;
//通过代理工厂创建一个service工厂
XFireProxyFactory serviceFactory = new XFireProxyFactory() ;
try {
SayHiService service =(SayHiService)serviceFactory.create(serviceModel, serviceURL) ;
String hello = service.sayHi("张三") ;
System.out.println("Server返回信息:"+hello) ;
}
catch (MalformedURLException e)
{
e.printStackTrace();
}
选中xfire,下载xfire的包导入
2、写一个接口
3、写一个实现类
4、新建一个web service client 测试类
在main中加入
String serviceURL = "http://localhost:808/webserviceDemo/services/sayHi" ;
//此处的URL为WSDL所在URL
Service serviceModel = new ObjectServiceFactory().
create(SayHiService.class,
null,
"http://localhost:808/webserviceDemo/services/sayHi?wsdl", null) ;
//通过代理工厂创建一个service工厂
XFireProxyFactory serviceFactory = new XFireProxyFactory() ;
try {
SayHiService service =(SayHiService)serviceFactory.create(serviceModel, serviceURL) ;
String hello = service.sayHi("张三") ;
System.out.println("Server返回信息:"+hello) ;
}
catch (MalformedURLException e)
{
e.printStackTrace();
}
本文详细介绍了如何使用xfire框架创建一个简单的WebService,并通过客户端进行测试的过程。包括新建项目、编写接口、实现类、配置及测试URL等关键步骤。
1268

被折叠的 条评论
为什么被折叠?



