webservice返回list

1.server-config.wsdd----部分

 

......

<service name="ManageService" provider="java:RPC">
  <parameter name="allowedMethods" value="*"/>
  <parameter name="className" value="cn.com.xinli.webservice.ManageService"/>
   <beanMapping
     languageSpecificType="java:cn.com.xinli.webservice.OnlineRecord"
     qname="ns1:or"
     xmlns:ns1="http://127.0.0.1:8080/gd/services/ManageService"/>
    

 <arrMapping qname="myNS:List" xmlns:myNS="http://127.0.0.1:8080/gd/services/ManageService"
       type="java:java.util.ArrayList"/>  

 </service>    

......

 

 

 

2.客户端调用

......

 //**  测试返回list

        String URL="http://127.0.0.1:8080/gd/services/ManageService";

        Service service = new Service();
         Call call = (Call)service.createCall();
        call.setTargetEndpointAddress(URL);
      List <OnlineRecord>list= null;
  
        call.setTargetEndpointAddress(URL);
       
       
        QName qn1 = new QName(URL,"or");
        call.registerTypeMapping(
          OnlineRecord.class,
          qn1,
          new BeanSerializerFactory(OnlineRecord.class,qn1),  //序列化工厂
          new BeanDeserializerFactory(OnlineRecord.class,qn1) //反序列化工厂
          );
       
        QName qn = new QName(URL,"ArrayList");
        call.registerTypeMapping(
          ArrayList.class,
          qn,
          new BeanSerializerFactory(ArrayList.class,qn),  //序列化工厂
          new BeanDeserializerFactory(ArrayList.class,qn) //反序列化工厂
          );
       
        call.setOperationName(new QName(URL,"GetOnlineRecordWork"));
       
        String str1="c00000048672";
        String str2="1900-01-10 23:20:34";
        String str3="2012-12-10 23:30:40";
       
        call.addParameter("str1", XMLType.XSD_STRING, ParameterMode.IN);
        call.addParameter("str2", XMLType.XSD_STRING, ParameterMode.IN);
        call.addParameter("str3", XMLType.XSD_STRING, ParameterMode.IN);
 
        call.setReturnClass(List.class);

       list= (List) call.invoke(new Object[]{str1,str2,str3});
      
    
    for(OnlineRecord or:list)
    {
     System.out.println("or=>"+or.getVLogin_ID()+" "+or.getVNASIP());
    } 
  ......    

你可能感兴趣的:(webservice)