smack+ejabberd用户查询问题

1:用smack访问ejabberd,如何判断用户名是否被注册过?
2:网上看某位大神写的查询用户的代码,看起来写的好有道理,可是为什么用在我的项目里面,会报503错误呢?
public static List searchUsers(XMPPConnection connection,String serverDomain,String userName) throws XMPPException

{

List results = new ArrayList();

System.out.println("查询开始..............."+connection.getHost()+connection.getServiceName());

    UserSearchManager usm = new UserSearchManager(connection);  


    Form searchForm = usm.getSearchForm(serverDomain);  
    Form answerForm = searchForm.createAnswerForm();  
    answerForm.setAnswer("Username", true);  
    answerForm.setAnswer("search", userName);  
    ReportedData data = usm.getSearchResults(answerForm, serverDomain);  

     Iterator<Row> it = data.getRows();  
     Row row = null;  
     UserBean user = null;  
     while(it.hasNext())  
     {  
         user = new UserBean();  
         row = it.next();  
         user.setUserName(row.getValues("Username").next().toString());  
         user.setName(row.getValues("Name").next().toString());  
         user.setEmail(row.getValues("Email").next().toString());  
         System.out.println(row.getValues("Username").next());  
         System.out.println(row.getValues("Name").next());  
         System.out.println(row.getValues("Email").next());  
         results.add(user);  
         //若存在,则有返回,UserName一定非空,其他两个若是有设,一定非空  
     }  

     return results;  
}  
    哪位大神能抽空帮我解答一下吗?不胜感激
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐