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、生成客户端:
跟本地调用一样