求助XFire开发webservice时返回List问题

请各位高手帮忙!!!
问题是:客户端调用webservice时,调用的方法不停的执行,加了打印语句,就不停的打印aaaaaaaaaaaaa,调用代码:list = client.getAllUser();
以下是代码:

服务接口:
package com.zhang.interfaces;

import java.util.List;

import com.smc.entity.UserInfo;


public interface UserService {

public UserService getUser(String userid);

public List <UserService> getAllUser();

    public String getUserid() ;
   
    public void setUserid(String userid) ;

    public String getUsername() ;
   
    public void setUsername(String username) ;

    public String getLogin() ;
   
    public void setLogin(String login) ;

    public String getPw();
   
    public void setPw(String pw);

    public String getSex();
   
    public void setSex(String sex) ;

    public String getBirthday();
   
    public void setBirthday(String birthday) ;

    public String getNativeplace() ;
   
    public void setNativeplace(String nativeplace);

    public String getNation();
   
    public void setNation(String nation) ;

    public String getTelephone();
   
    public void setTelephone(String telephone);

    public String getEmail();
   
    public void setEmail(String email);
}
服务实现类:
package com.smc.entity;

import java.util.ArrayList;
import java.util.List;

import org.hibernate.Session;

import com.smc.struts.HibernateSessionFactory;
import com.zhang.interfaces.UserService;


/**
* UserInfo generated by MyEclipse - Hibernate Tools
*/

public class UserInfo  implements java.io.Serializable ,UserService{


    // Fields   

    private String userid;
    private String username;
    private String login;
    private String pw;
    private String sex;
    private String birthday;
    private String nativeplace;
    private String nation;
    private String telephone;
    private String email;


    // Constructors

    /** default constructor */
    public UserInfo() {
    }

/** minimal constructor */
    public UserInfo(String username, String login, String pw) {
        this.username = username;
        this.login = login;
        this.pw = pw;
    }
   
    /** full constructor */
    public UserInfo(String username, String login, String pw, String sex, String birthday, String nativeplace, String nation, String telephone, String email) {
        this.username = username;
        this.login = login;
        this.pw = pw;
        this.sex = sex;
        this.birthday = birthday;
        this.nativeplace = nativeplace;
        this.nation = nation;
        this.telephone = telephone;
        this.email = email;
    }
    public List <UserService> getAllUser(){
    System.out.println("aaaaaaaaaaaaa");
    List <UserService> list = new ArrayList <UserService>();
    List arr = new ArrayList();
    Session session = HibernateSessionFactory.getSession();
    String hql = "from UserInfo";
    arr = session.createQuery(hql).list();
    session.close();
    if(!arr.isEmpty()){
    for(int i = 0;i <arr.size();i++){
    System.out.println(arr.get(i).getClass().toString());
    UserInfo user = (UserInfo)arr.get(i);
    UserService ss = user;
    list.add(ss);
    }
    }
   
    return list;
   
    }
public UserService getUser(String userid){
UserService user = null;
Session session = HibernateSessionFactory.getSession();
user = (UserService)session.get(UserInfo.class, userid);
session.close();
String username = user.getLogin();
System.out.println("=====>"+username);
return user;
}
 
    // Property accessors

    public String getUserid() {
        return this.userid;
    }
   
    public void setUserid(String userid) {
        this.userid = userid;
    }

    public String getUsername() {
        return this.username;
    }
   
    public void setUsername(String username) {
        this.username = username;
    }

    public String getLogin() {
        return this.login;
    }
   
    public void setLogin(String login) {
        this.login = login;
    }

    public String getPw() {
        return this.pw;
    }
   
    public void setPw(String pw) {
        this.pw = pw;
    }

    public String getSex() {
        return this.sex;
    }
   
    public void setSex(String sex) {
        this.sex = sex;
    }

    public String getBirthday() {
        return this.birthday;
    }
   
    public void setBirthday(String birthday) {
        this.birthday = birthday;
    }

    public String getNativeplace() {
        return this.nativeplace;
    }
   
    public void setNativeplace(String nativeplace) {
        this.nativeplace = nativeplace;
    }

    public String getNation() {
        return this.nation;
    }
   
    public void setNation(String nation) {
        this.nation = nation;
    }

    public String getTelephone() {
        return this.telephone;
    }
   
    public void setTelephone(String telephone) {
        this.telephone = telephone;
    }

    public String getEmail() {
        return this.email;
    }
   
    public void setEmail(String email) {
        this.email = email;
    }
}


service.xml

<beans xmlns="http://xfire.codehaus.org/config/1.0">
<service>
<name>UserService </name>
<namespace>user </namespace>
<serviceClass>
com.zhang.interfaces.UserService
</serviceClass>
<implementationClass>
com.smc.entity.UserInfo
</implementationClass>
</service>
</beans>


客户端调用:
public class Client{
  public List <UserService> callUsers(){
List <UserService> list = new ArrayList <UserService>();   
        Service serviceModel = (new ObjectServiceFactory().create(UserService.class));       

        XFire xfire = XFireFactory.newInstance().getXFire();
        XFireProxyFactory factory = new XFireProxyFactory(xfire);     
 
        String serviceUrl = "http://localhost:8080/zhnSMC/services/UserService";
     
        UserService client = null;
        try {
            client = (UserService) factory.create(serviceModel, serviceUrl);
           
        } catch (MalformedURLException e) {
          // log.error("WsClient.callWebService(): EXCEPTION: " + e.toString());
        }   

        try {
        list = client.getAllUser();
        System.out.println(list.size());
      } catch (Exception e){

        }       
return list;
}
public static void main(String[] args){
Client client = new Client();
List <UserService> list = client.callUsers();
}

}

你可能感兴趣的:(webservice)