zhxfresh 2015-04-27 01:26
浏览 1233

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;  
}  
    哪位大神能抽空帮我解答一下吗?不胜感激
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 如何在scanpy上做差异基因和通路富集?
    • ¥20 关于#硬件工程#的问题,请各位专家解答!
    • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
    • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
    • ¥30 截图中的mathematics程序转换成matlab
    • ¥15 动力学代码报错,维度不匹配
    • ¥15 Power query添加列问题
    • ¥50 Kubernetes&Fission&Eleasticsearch
    • ¥15 報錯:Person is not mapped,如何解決?
    • ¥15 c++头文件不能识别CDialog