XFire的HelloWorld!
来源:互联网 发布:重庆简米网络培训骗局 编辑:程序博客网 时间:2024/05/14 10:54
之前有写过helloworld可是写得很差,我想一定有很多人看不懂。现在我将步骤截图下来
1.创建服务器端,创建一个web Services Project
2.创建一个接口和一个实现类
public interface IWearther {
/**
* @return 返回字符串,用于显示天气
*/
public String wearther();
}
public class IWeartherImpl implements IWearther {
/**
* @return 返回字符串,用于显示天气
*/
public String wearther() {
String result = "根据一系列处理得到当前天气为阴天!";
return result;
}
}
3.修改webServices文件夹下的services.xml
<service>
<name>Wearther</name>
<namespace>www.jungle.com/Weather</namespace><!-- 网站域名+上面节点name -->
<serviceClass>com.jungle.IWearther</serviceClass><!-- 接口 -->
<implementationClass>
com.jungle.IWeartherImpl
</implementationClass><!-- 实现类 -->
</service>
PS:简单的服务器就创建完成了,
4.创建客户端,这里要注意的是创建的是WebProject
首先引入需要的jar包:
5.在客户端创建接口,名称不用和服务器端一样,但是方法要和服务器端一模一样。
public interface IWeartherClient {
/**
* @return 返回字符串,用于显示天气,方法要和服务器端的方法完全一样。
*/
public String wearther();
}
6.测试类:
import java.net.MalformedURLException;import org.codehaus.xfire.client.XFireProxyFactory;import org.codehaus.xfire.service.Service;import org.codehaus.xfire.service.binding.ObjectServiceFactory;//http://fxk2006.iteye.com/blog/618802public class TestMain { public static void main(String[] args) throws MalformedURLException { Service service = new ObjectServiceFactory().create(IWeartherClient.class); // 地址 + 服务器端的<url-pattern>/services/*</url-pattern> + 服务器端的services.xml中的<name>Wearther</name> String url = "http://localhost:8000/XFireTest/services/Wearther"; IWeartherClient client = (IWeartherClient) new XFireProxyFactory().create(service, url);// 得到本地的接口 System.out.println(client.wearther()); }}
- XFire的HelloWorld!
- XFire Web Service的HelloWorld
- WebService的 HelloWorld : XFire , JAX-WS , JSR181
- xfire基础一: helloworld
- xfire开发实例--HelloWorld篇
- xfire开发实例--HelloWorld篇
- xfire开发实例--HelloWorld篇
- xfire开发实例两个方法--HelloWorld篇
- XFire+MyEclipse 开发WebService入门实例之HelloWorld
- XFire+MyEclipse 开发WebService入门实例之HelloWorld
- XFire客户端的实现
- xfire的客户端开发
- XFire奇怪的问题
- xfire的客户端开发
- XFire的aegis绑定!!!
- XFire的使用
- xfire遇到的问题
- xfire的jaxb2实例
- 数字频率,模拟频率,模拟角频率
- SQL基础1——select查询
- samba 服务器的搭建
- 获取包下的所有类
- good website
- XFire的HelloWorld!
- visual studio静态,动态链接库开发工具简单使用
- js :parentNode,firstChild,parentNode,nextSibling;
- jsp页面 后台程序 与javascript的交互
- 为了下资源
- Android 源码编译以及系统内置应用Contacts开发
- udl文件的创建
- 辅导九期同学装机、装系统
- C#学习笔记