My problem is that I need to interact with a vendor that provides a SOAP API. And I've never done SOAP. So I've run into some trouble.

What I'm supposed to do is call the login method, then go on to call methods that do work, then logout when I'm done. I'm able to call the login method. I can tell that login worked. But then I'm unable to do anything else.

Here is some sample code:

#! /usr/bin/perl -wl use strict; use SOAP::Lite; use Data::Dumper; $Data::Dumper::Indent = 1; my $soap = SOAP::Lite->uri( 'https://ws1.responsys.net/webservices/ResponsysWS?wsdl' )->proxy( 'https://ws1.responsys.net/webservices/ResponsysWS?wsdl' ); my $return = $soap->login('USER', 'PASSWORD'); #print Dumper($return); if ($return->fault) { die $return->faultstring; } $return = $soap->listFolders(); if ($return->fault) { die $return->faultstring; }
The response I get is:
java.rmi.RemoteException: RIAccount object is not available in session + at test.pl line 24.
which is coming from the attempt to call listFolders. (If you run this you'll get a different error since I haven't provided you with the right login information - login really did something.) So obviously there is an RIAccount object that I need to find and do something. But I can't find anything appropriate when I look through the datastructures I have available in $soap or $response.

When I compare with the Java code example in the documentation I see an interesting call to:

((ResponsysWSSoapBindingStub) service).setMaintainSession(true);
that looks like it could be relevant to keeping a login around. But I can't figure out what the Perl equivalent might be. (If there is one.)

Of course the interface is defined with WSDL. And if I look at WSDL examples in Perl, I see that might be better off calling the session method. However that produces an immediate error. Based on http://support.microsoft.com/kb/308438 I tried downloading the WSDL and deleting the wsdl:portType section. Now I don't get an error, but I get nothing back from:

#! /usr/bin/perl -wl use strict; use SOAP::Lite; use Data::Dumper; $Data::Dumper::Indent = 1; my $soap = SOAP::Lite->service( 'file://users/btilly/responsys/ResponsysWS.wsdl' )->proxy( 'https://ws1.responsys.net/webservices/ResponsysWS?wsdl' ); $soap->login('USER', 'PASSWORD'); print $soap->listFolders;
which isn't very useful. Possibly related is that the datastructure of $soap includes a fault:
'org.xml.sax.SAXParseException: The value of the attribute "p refix="xmlns",localpart="namesp1",rawname="xmlns:namesp1"" is invalid. + Prefixed namespace bindings may not be empty.'
and I don't know where this comes from.

Does anybody have ideas for what else I can try to be able to login to the service then start calling useful methods? (If it involves ignoring the WSDL and hand-coding stuff, I'm fine with that as long as I have an example to work from to let me know what I should be hand-coding.)


In reply to SOAP::Lite and sessions? by tilly

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.