欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

xfire的webservice示例

程序员文章站 2022-03-11 21:41:01
...
1、首先将xfire需要的jar包上传的项目中。
xfire的webservice示例
            
    
    博客分类: Java Web技术分析

项目的结构图:
xfire的webservice示例
            
    
    博客分类: Java Web技术分析

2、在web.xml文件中配置xfire信息
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
   http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

	<servlet>
		<servlet-name>XFireServlet</servlet-name>
		<servlet-class>
			org.codehaus.xfire.transport.http.XFireConfigurableServlet
		</servlet-class>
	</servlet>
	<servlet-mapping>
		<servlet-name>XFireServlet</servlet-name>
		<url-pattern>/servlet/XFireServlet/*</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
		<servlet-name>XFireServlet</servlet-name>
		<url-pattern>/services/*</url-pattern>
	</servlet-mapping>
	<!-- 加载属性文件 用于读取jdbc信息 -->
	<listener>
		<listener-class>com.fysh.listener.PropListener</listener-class>
	</listener>
</web-app>


代码中配置了一个监听器,我使用监听器加载jdbc的信息保存在内存中。
3、定义接口并实现
package com.fysh.service;

public interface FyshService {
	
	/**
	 * 门诊审核信息
	 * @param xml_mz_ycxx
	 * @return
	 */
	public String upload_mz_ycxx(String xml_mz_ycxx);
	
	/**
	 * 住院审核信息
	 * @param xml_zy_ycxx
	 * @return
	 */
	public String upload_zy_ycxx(String xml_zy_ycxx);
	
	/**
	 * 门诊信息反馈
	 * @param xml_mz_ycxx
	 * @return
	 */
	public String download_mz_ycxx(String xml_mz_ycxx);
	
	/**
	 * 住院信息反馈
	 * @param xml_zy_ycxx
	 * @return
	 */
	public String download_zy_ycxx(String xml_zy_ycxx);
	
	
	/**
	 * 阀值信息
	 * @param xml_mz_fzxx
	 * @return
	 */
	public String download_fzxx(String xml_fzxx);
	
}

接口的实现类
package com.fysh.service.impl;

import java.util.Map;

import com.fysh.dao.FyshDao;
import com.fysh.service.FyshService;

public class FyshServiceImpl implements FyshService {
	
	

	/**
	 * 获取门诊审核反馈信息
	 */
	public String download_mz_ycxx(String xml_mz_ycxx) {
		String resXml="<xml_mz_ycxx_fk>";
		FyshDao dao = new FyshDao();
		Map<String,String> resMap = dao.getMzYcxx(xml_mz_ycxx);
		for (String key : resMap.keySet()) {
			resXml = resXml +"<"+key+">"+resMap.get(key)+"</"+key+">";
		}
		resXml = resXml + "</xml_mz_ycxx_fk>";
		return resXml.toLowerCase();
	}

	/**
	 * 获取住院审核反馈信息
	 */
	public String download_zy_ycxx(String xml_zy_ycxx) {
		String resXml="<xml_zy_ycxx_fk>";
		FyshDao dao = new FyshDao();
		Map<String,String> resMap = dao.getZyYcxx(xml_zy_ycxx);
		for (String key : resMap.keySet()) {
			resXml = resXml +"<"+key+">"+resMap.get(key)+"</"+key+">";
		}
		resXml = resXml + "</xml_zy_ycxx_fk>";
		return resXml.toLowerCase();
	}
	
	/**
	 * 提交门诊审核信息
	 */
	public String upload_mz_ycxx(String xml_mz_ycxx) {
		String resXml="<xml_mz_ycxx><isok>";
		FyshDao dao = new FyshDao();
		boolean resFlag = dao.saveMzYcxx(xml_mz_ycxx);
		resXml = resXml+resFlag +"</isok></xml_mz_ycxx>";
		return resXml.toLowerCase();
	}
	
	/**
	 * 提交住院审核信息
	 */
	public String upload_zy_ycxx(String xml_zy_ycxx) {
		String resXml="<xml_mz_ycxx><isok>";
		FyshDao dao = new FyshDao();
		boolean resFlag = dao.saveMzYcxx(xml_zy_ycxx);
		resXml = resXml+resFlag +"</isok></xml_mz_ycxx>";
		return resXml.toLowerCase();
	}
	
	/** 
	 * 获取阀值信息
	 */
	public String download_fzxx(String xml_fzxx) {
		String resXml="<xml_fzxx>";
		FyshDao dao = new FyshDao();
		Map<String,String> resMap = dao.getFzxx(xml_fzxx);
		for (String key : resMap.keySet()) {
			resXml = resXml +"<"+key+">"+resMap.get(key)+"</"+key+">";
		}
		resXml = resXml+"</xml_fzxx>";
		return resXml.toLowerCase();
	}

}


4、调用的类
XFireProxyFactory factory = new XFireProxyFactory(XFireFactory.newInstance().getXFire());
		Client client = new Client(new URL("http://localhost:8080/fysh_webservice/services/fysh?wsdl"),FyshService.class);
 String xml_zy_fk="<xml_zy_ycxx_fk><jgbm>310114117</jgbm><zylsh>34534532</zylsh></xml_zy_ycxx_fk>";
	   System.out.println(((FyshService)factory.create(client)).download_zy_ycxx(xml_zy_fk));
  • xfire的webservice示例
            
    
    博客分类: Java Web技术分析
  • 大小: 23 KB
  • xfire的webservice示例
            
    
    博客分类: Java Web技术分析
  • 大小: 23.8 KB