The list problem is returned when xfire is used to develop WebService.

Source: Internet
Author: User

Please help me !!!
The problem is: when the client calls WebService, The called method is continuously executed. When a print statement is added, aaaaaaaaaaaaa is continuously printed and called.Code: List = client. getalluser ();
The following code is used:

Service Interface:
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 );
}
Service implementation class:
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>

client call:
public class client {
public list callusers () {
List List = new arraylist ();
service servicemodel = (New objectservicefactory (). create (userservice. class);

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 ();
}

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.