求教XFire返回自定义对象的问题

User类:
public class User {
private String name;

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}
}

public interface UserService {
public User getUser();
}

实现类:
public class UserServiceImpl implements UserService {

public User getUser(){
User u = new User();
u.setName("test");
return u;
}

}

web.xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<servlet>
<servlet-name>XFireServlet</servlet-name>
<servlet-class>org.codehaus.xfire.spring.XFireSpringServlet</servlet-class>
<load-on-startup>0</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>XFireServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>

<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>


applicationContext.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" />
<!-- base service -->
<bean id="webService" class="org.codehaus.xfire.spring.remoting.XFireExporter" lazy-init="false"
abstract="true">
<property name="serviceFactory" ref="xfire.serviceFactory" />
<property name="xfire" ref="xfire" />
<property name="scope" value="application"/>
<property name="use" value="literal"/>
<property name="style" value="wrapped"/>
</bean>

<bean id="userService" parent="webService">
<property name="serviceBean" ref="userServiceImpl" />
<property name="serviceClass" value="UserService" />
<property name="name" value="UserService"/>
</bean>

<bean id="userServiceImpl" class="UserServiceImpl"/>
</beans>


客户端调用代码:
public static void main(String[] args) {

Service srvcModel = new ObjectServiceFactory()
.create(UserService.class);
XFireProxyFactory factory = new XFireProxyFactory(XFireFactory
.newInstance().getXFire());
String url= "http://localhost:8080/ws/services/UserService";
try {
UserService srvc = (UserService) factory.create(
srvcModel, url);
User u= srvc.getUser();
System.out.println(u.getName());
} catch (MalformedURLException e) {
e.printStackTrace();
}

}

打印出来的结果为:null
理论上来说USER类里面,只有String这样的基本类型,不要什么映射就可以了,但是还得不到值,百思不得其解,期待那个高*手指点指点....多谢!!!
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值