Myeclipse 搭建 webservice XFire
Myeclipse6.0 搭建webservice XFire
1.新建web工程名为wsdemo
2.右键wsdemo 》 MyEclipse 》Add Web service capabilities 》Next 》
√ MyEclipse Libraries 》
√ Xfire 1.2 Core Libraries
√ Xfire 1.2 HTTP Client Libraries
》Finish
3.服务端结构
4.浏览器测试
http://127.0.0.1:6666/wsdemo/services?wsdl
点击wsdl,出现个想xml的东东表示ok。
服务端ok。
--------------------------------
下面是客户端
客户端以String url = "http://127.0.0.1:6666/wsdemo/services/weather";访问(url最好写到配置文件)。
客户端结构:
附录1.服务端代码
1.
4.web.xml文件
附录2.客服端代码
1.package com.itjob.app;import java.net.MalformedURLException;import org.codehaus.xfire.XFire;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.itjob.dao.GetWeather;public class MainApp {public static void main(String[] args) {// TODO Auto-generated method stubService service = new ObjectServiceFactory().create(GetWeather.class);XFire xFire = XFireFactory.newInstance().getXFire();XFireProxyFactory factory = new XFireProxyFactory(xFire);String url = "http://127.0.0.1:6666/wsdemo/services/weather";try {GetWeather gw = (GetWeather) factory.create(service, url);System.out.println(gw.get(6));} catch (MalformedURLException e) {// TODO Auto-generated catch blocke.printStackTrace();}}}
运行main。。。