问题
I am using a binary release of Asmack (I will be building it as soon as I have some time as I had problems the first time I tried). I also set up my own ejabberd server.
When I try to load some contact VCard the server returns the info but Asmack does not seem to like it (or fail to parse it).
This is what I can see in debug mode:
<iq from='user@domain' to='admin@domain/Smack' id='I17sI-4' type='result'>
<vCard xmlns='vcard-temp' prodid='-//HandGen//NONSGML vGen v1.0//EN' version='2.0'>
<FN>Full Name</FN>
<N>
<FAMILY>Surname</FAMILY>
<GIVEN>Nick</GIVEN>
</N>
<NICKNAME>Nickname</NICKNAME>
<URL>http://google.com</URL>
<ADR>
<LOCALITY>lanta</LOCALITY>
<REGION>krabi</REGION>
<PCODE>81150</PCODE>
<CTRY>thailand</CTRY>
</ADR>
<EMAIL>
<USERID>user@domain.com</USERID>
</EMAIL>
</vCard>
</iq>
But when I do
VCard card = new VCard();
card.load(xmppConn, "user@domain");
All the info is set to null, and when I try to look at the XML by calling VCard.toXML() method I just got an empty XML like this
<iq id="I17sI-4" to="user@domain" type="get"><vCard xmlns='vcard-temp'/></iq>
So anyone knows what I am doing wrong or if this binary release that fails to parse the VCard received from the server?
回答1:
Add line: ProviderManager.getInstance().addIQProvider("vCard", "vcard-temp", new VCardProvider());
before loading vCard.
来源:https://stackoverflow.com/questions/8355684/asmack-not-loading-vcard