xz0312221 2008-11-26 15:35
浏览 283
已采纳

xfire服务器端返回自定义对象中包含hashmap的问题

我在项目中遇到这样一个问题,webservice服务器段用xfire实现,暴露的service方法返回一个自定义的对象ClaimNodeTimes(后面会贴出代码),这个对象中一个属性refusePayReason是HashMap<string,string>类型。

然后我用xfire的eclipse插件生成的测试代码进行测试,发现ClaimNodeTimes对象中的基本类型属性都能取到值,但是refusePayReason是空的,哪位遇到过这种问题,麻烦给解释下。

贴出代码如下:

自定义对象ClaimNodeTimes

public class ClaimNodeTimes {


 private HashMap<string,string> refusePayReason;



 public HashMap<string,string> getRefusePayReason() {
  return refusePayReason;
 }


 public void setRefusePayReason(HashMap<string,string> refusePayReason) {
  this.refusePayReason = refusePayReason;
 }



}

这里还有个问题,我看xfire的文档中说使用java5的泛型,就可以不用对collections 做aegis binding,但我发现即便使用了泛型在客户端生成的代码中refusePayReason的类型仍然是anyType2anyTypeMap,所以还是写了aegis binding,refusePayReason的类型就成了String2StringMap,如下:

 

   
<mappings xmlns:vo="http://vo.customer.claim.picc.com.cn">
<mapping name="vo:ClaimNodeTimes">  
<property name="refusePayReason" keytype="java.lang.String" componenttype="java.lang.String">
</mapping>   
</mappings>

暴露的service:

 

public interface CustomerWebServices {

public ClaimNodeTimes findClaimNodeTimesByRegistNo(String registNo);

}

 

对service的aegis binding:

<mappings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance " xsi:schemalocation="http://xfire.codehaus.org/schemas/1.0/mapping.xsd ">
  <mapping>
    <method name="findClaimNodeTimesByRegistNo">
      <return-type componenttype="cn.com.picc.claim.customer.vo.ClaimNodeTimes">
    </method>
  </mapping>
</mappings>

服务器端xfire的配置:


<beans>
 <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
  <property name="urlMap">
   
    <entry key="/CustomerWebServices">
     <ref bean="customers">
    </entry>

   
  </property>
 </bean>
 
 
 <bean id="customers" class="org.codehaus.xfire.spring.remoting.XFireExporter" lazy-init="false">
  <property name="serviceFactory">
   <ref bean="xfire.serviceFactory">
  </property>
  <property name="xfire">
   <ref bean="xfire">
  </property>
  <property name="serviceBean">
   <ref bean="customerWebServices">
  </property>
  <property name="serviceClass">
   <value>cn.com.picc.claim.customer.service.facade.CustomerWebServices</value>
  </property>
 </bean>


</beans>

 

service配置:


<beans default-autowire="byName" default-lazy-init="true">

<bean id="customerWebServices" class="cn.com.picc.claim.customer.service.spring.CustomerWebServiceSpringImpl" scope="prototype">

</beans>

 

下面是用xfire的eclipse插件生成的测试代码:

public class TestMain {
 public static void main(String[] args){
  CustomerWebServicesClient client=new CustomerWebServicesClient();
  ClaimNodeTimes array = client.getCustomerWebServicesHttpPort()
  .findClaimNodeTimesByRegistNo("RDAA200835020000004015");

String2StringMap temp = array.getRefusePayReason().getValue();
  List list = temp.getEntry();
  System.out.println(list.size());

}

 

我debug的时候,在服务器端接口实现中ClaimNodeTimes对象的refusePayReason是有值的,但list的size为0.

哪位能指点一下?

 

  • 写回答

1条回答 默认 最新

  • earthsky 2008-12-05 16:51
    关注

    <?xml version="1.0" encoding="UTF-8"?>

    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">

    class="cn.com.picc.claim.customer.service.spring.CustomerWebServiceSpringImpl" scope="prototype" />



    是不是[color=red]default-lazy-init=“true”[/color]的原因,你改为false试试,哈哈。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型
  • ¥15 求学软件的前人们指明方向🥺
  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 STM32驱动继电器