bfaist has asked for the wisdom of the Perl Monks concerning the following question:

I can successfully make an RPC method call with Jabber::RPC::Client but I would rather use Net::Jabber::Client but the authorization seems to fail. Any ideas?

Using Jabber::RPC::Client

use Jabber::RPC::Client; my $client = Jabber::RPC::Client->new(server=>'localhost', identauth=>'emsng:emsng', endpoint=>'dst@localhost/XMLRPC' +, ); my $response = $client->call('CreateContext', { ApplicationName=>'EMSng', MaxIdleDuration=>'5' } ); print $response || $client->lastfault, "\n";

Using Net::Jabber::Client

use Net::Jabber qw( Client ); my $client = Net::Jabber::Client->new(); my $status; $client->Connect(hostname=>'localhost'); if($client->Connected()) { $status = $client->AuthSend(username=>'emsng', password=>'emsng'); my @response = $client->RPCCall(to=>'dst@localhost/XMLRPC', methodname=>'CreateContext', params=>[ { ApplicationName=>'EMSngTEST', MaxIdleDuration=>'5' } ] ); die Dumper(\@response); }

Response when use Net::Jabber::Client

<packet xmlns="http://www.jivesoftware.org" streamID="94d182bf" status +="connected" timestamp="Mar 1, 2006 11:36:52 AM"><iq xmlns="" type="e +rror" id="netjabber-0" to="localhost/94d182bf"><query xmlns="jabber:i +q:rpc"><methodCall><methodName>CreateContext</methodName><param s><pa +ram><value><struct><member><name>MaxIdleDuration</name><value><i4>5</ +i4></value></member><memb +er><name>Ap plicationName</name><value><st +ring>EMSngTEST</string></value></member></struct></value></param></pa + +rams></meth odCall></query><error code="401" type="auth"><not-autho +rized xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></er ror></iq></pa +cket>

Edited by planetscape - added readmore tags and minor adjustments to formatting

Replies are listed 'Best First'.
Re: Net::Jabber RPCCall
by duckyd (Hermit) on Mar 02, 2006 at 20:28 UTC
    Not terribly specific to Jabber RPC, but I'd say to dump your requests and see how they differ. If you were submitting identical requests, you'd sure hope to see identical responses.
Re: Net::Jabber RPCCall
by bfaist (Novice) on Mar 09, 2006 at 19:25 UTC
    The answer was to use $client->AuthIQAuth() instead of $client->AuthSend(). Connecting with SASL did not work so used old method (AuthIQAuth) instead.