⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 webservice.txt

📁 Java大部分的基础知识,EJB3,EJB2,WEBSERVICE,SOAP,JMS,MQ,还有些面试题
💻 TXT
字号:
webservice讲义

webservice的作用
	跨平台 跨语言 跨系统 是分布的另一种实现 
	客户可以直接调用服务对象的方法。
webservice所用的协议
	tcp/ip-->http-->soap
	soap(simple object access protocal)简单对象访问协议
webservice数据传送的介质
	xml
webservice的角色
	服务提供商:提供真正的服务,将服务部署到服务代理商处。
	服务代理商:将服务提供商的服务公开,通过wsdl(web service description language)
		   进行描述,其别名是uddi中心
	客户端:通过服务代理商找到服务提供商。
	处理过程:
		客户端通过服务代理商找到服务提供商,直接与服务提供商交互。
xfire如何实现webservice
	1、在web.xml中部署xfire对应的servlet
	2、加入一个接口及实现类
	3、在src/META-INF/xfire目录中加入services.xml,说明
	   需要部署的接口及实现类
	4、通过http://localhost:8080/chap01/services该问该类对应的
		wsdl
	5、写客户端代码实现
		--说明请求接口即源
		Server source=new ObjectServerFactory().create(IHello.class);
		--产生一个代理会话
		XFire xfire=XFireFactory.newInstance().getXFire();
		XfireProxyFactory xpf=new XfireProxyFactory(xfire);
		String url="http://localhost:8080/chap01/services/Hello";
		--得到一个接口,远程调用服务端的方法
		IHello hello=(IHello)xpf.create(source,url);
如何传送对象
	--字节到对象
		ByteArrayInputStsream bis=new ByteArrayInputStream(bytes);
		ObjectInputStream ois=new ObjectInputStream(bis);
		Customer customer=(Customer)ois.readObject();
	--对象到字节
		ByteArrayOutputStream bos=new ByteArrayOutputStream();
		ObjectOutputStream oos=new ObjectOutputStream(bos);
		--将对象写出输出的字节流中
		oos.writeObject(customer);
		--将输出字节流转化字节数组


四、xfire实现webservice
	Service source=new ObjectServiceFactory().create(IHello.class):得到源数据
	//得到服务代理
	Xfire xfire=XfireFactory.newInstance().getXfire();
	XfireProxyFactory factory=new XfireProxyFactory(xfire);
	//调用服务端的方法
	IHello hello=factory.create(sourc,url);
	String result=hello.sayHello();
		bos.toArray();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -