我是ejabberd android的新手。我可以成功发送和接收消息,但我无法使用Android中的UserSearchManager搜索用户详细信息,它始终返回503错误。我的代码如下:
代码:
//mConnection in XMPP Connection Object
UserSearchManager usm = new UserSearchManager(mConnection);
List<String> services = usm.getSearchServices();
//usm.gersearchservice() size always 0
//if (services == null || services.size() < 1)
for (String service: services) {
Log.e("SERVICE", service);
}
Form searchForm = usm.getSearchForm("service."+mConnection.getServiceName());
Form answerForm = searchForm.createAnswerForm();
answerForm.setAnswer("Username", true);
answerForm.setAnswer("search", "ashok25");
ReportedData data = null;
data = usm.getSearchResults(answerForm, mConnection.getServiceName());
Iterator<ReportedData.Row> it = (Iterator<ReportedData.Row>) data.getRows();
结果:
D/SMACK: SENT (0): <iq to='search.xxx.yyy.zzz' id='59h51-23' type='get'><query xmlns='jabber:iq:search'/></iq>
D/SMACK: RECV (0): <iq from='search.xxx.yyy.zzz' to='ashok@search.xxx.yyy.zzz/Smack' type='error' xml:lang='en' id='59h51-23'><query xmlns='jabber:iq:search'/><error code='503' type='cancel'><service-unavailable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/><text xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'>No s2s connection found</text></error></iq><r xmlns='urn:xmpp:sm:3'/>