xfire发布webservice

1、实体:

package com.csair.xfire;

public class User {

	private String name;
	private String password;
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	
	
}

2、接口:

package com.csair.xfire;

public interface UserService {

	User getUser();
	
	String request(String username, String password, String methodName,  String requestXML);
}

3、实现:

package com.csair.xfire;


import org.apache.log4j.Logger;




public class UserServiceImpl implements UserService {


	private Logger log = Logger.getLogger(this.getClass());
	@Override
	public User getUser() {
		User user = new User();
		user.setName("ppt");
		user.setPassword("ppt");
		return user;
	}
	void test() {
//		XFireSpringServlet d;
	}
	@Override
	public String request(String username, String password, String methodName, String requestXML) {
		log.info(username);
		log.info(password);
		log.info(methodName);
		log.info(requestXML);
		return "ok";
	}


	


}

4、appplicationContent.xml

<?xml version="1.0" encoding="UTF-8"?>   
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">  
<beans>  
    <import resource="classpath:org/codehaus/xfire/spring/xfire.xml" />  
    <bean id="baseWebService" class="org.codehaus.xfire.spring.remoting.XFireExporter" lazy-init="false" abstract="true">  
        <property name="serviceFactory" ref="xfire.serviceFactory" />  
        <property name="xfire" ref="xfire" />  
    </bean>  
    <bean id="userServiceImpl" class="com.csair.xfire.UserServiceImpl"></bean>    
    <bean id="userService" parent="baseWebService">    
        <property name="serviceBean" ref="userServiceImpl" />  
        <property name="serviceClass" value="com.csair.xfire.UserService" />   
    </bean>  
</beans>

5、web.xml

<servlet>
  	<servlet-name>xfire</servlet-name>
  	<servlet-class>org.codehaus.xfire.spring.XFireSpringServlet</servlet-class>
  </servlet>
  <servlet-mapping>
  	<servlet-name>xfire</servlet-name>
  	<url-pattern>/webservice/*</url-pattern>
  </servlet-mapping>

6、访问URL:

http://localhost:8889/bbginterface/webservice/UserService?wsdl

7、生成客户端:

跟本地调用一样

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值