3

I am retrieving vCard using asmack library. I am able to retrieve the vCard but the response is not exactly what I require, it only gives response

<iq id="3842p-8" to="lalit3686.android@gmail.com" type="get">
                                <vCard xmlns='vcard-temp'><FN>Lalit Poptani</FN>

The expected response is complete detail/information about the user as shown here

I had tried it as below,

VCard vCard = new VCard();
try {
        ProviderManager.getInstance().addIQProvider("vCard", "vcard-temp",
                                                            new VCardProvider());
        vCard.load(conn, user);
        Log.d("Vcard XML", vCard.toXML());
    } catch (XMPPException e) {
        e.printStackTrace();
    }

I had also tried using this answer configuring everything thats required. So, is there anything that is required further to retrieve the complete xml of user's vCard?

Community
  • 1
  • 1
Lalit Poptani
  • 67,150
  • 23
  • 161
  • 242
  • Hmn. I see you're running the query in exactly the same way [that appears to have worked for another SO user](http://stackoverflow.com/questions/8355684/asmack-not-loading-vcard). The only complication is your output appears to be getting cut off after the first entry. Does [this thread](http://code.google.com/p/asmack/issues/detail?id=14) help you at all? – MrGomez Mar 28 '12 at 09:00
  • Thanks for the comment, but I had already checked that also but its not working. – Lalit Poptani Mar 28 '12 at 09:03
  • Very strange. Though, I wonder: is `Log.d` really printing all of the XML? What does attaching a debugger have to say about this problem? – MrGomez Mar 28 '12 at 09:07
  • `Log.d("Vcard XML", vCard.toXML());` prints the output that I already had added. – Lalit Poptani Mar 28 '12 at 09:08
  • Thank you for your fast response, but I think you misunderstand. I'm dubious on whether `Log.d` may be truncating the message in some way. This seems to be consistent for its behavior: http://stackoverflow.com/a/4269700/517815. To be fair, this is a fairly short amount of text... – MrGomez Mar 28 '12 at 09:11
  • Thanks for the link, but it works for other coporate client server. It gives complete VCard response for other corporate client but for gmail I don't know whats the problem. – Lalit Poptani Mar 28 '12 at 09:16
  • Unfortunately, I'm stumped. According to the [vcard-temp specification](http://xmpp.org/extensions/xep-0054.html), you shouldn't be receiving a partial vCard like this unless your connection is somehow interrupted or line breaks and closures aren't being parsed properly. I think the next course of action is to start sniffing network traffic via `tcpdump` and figure out exactly what's being sent and being received over the wire. – MrGomez Mar 28 '12 at 09:35
  • might be... I am not having much idea about `tcpdump`. thanks for the info though. – Lalit Poptani Mar 28 '12 at 09:39
  • Please look at to this link, it might helpful for you http://android-vcard.googlecode.com/hg/examples/ReadExample.java – Lucifer Mar 29 '12 at 04:48
  • Thanks for the link but I am using asmack library and the one you have is different. – Lalit Poptani Mar 29 '12 at 04:59
  • have you tried getting information from vCard? I mean have you tried `vCard.getXXX();`? if it returns something then check does it returns true value? – Harry Joy Mar 30 '12 at 09:29

1 Answers1

1

Try it using regular Smack in a simple Java app (no android) where you can turn on the debug window (-Dsmack.debugEnabled=true) which will give you the raw stanzas being received from the server. This will at least confirm that the stanza's are correct. If they are not, then you have server problem. I think this is unlikely, since malformed stanzas would typically cause the connection to terminate since the client cannot parse the stream.

If they are correct, then there is probably a problem in the provider itself. According to the documentation, Smacks' VCard class is incomplete, so it is possible that the information being returned is simply not in the list of fields that are parsed.

Knowing the stanza returned would make it easier to verify this.

asmack is derived from Smack so it should behave the exact same way in this particular case (most all cases actually).

Robin
  • 24,062
  • 5
  • 49
  • 58