Hi monks,
I am trying to retrieve data from a web server using a SOAP API.
Unfortunately, all the examples are in Java :(
In the past I have managed to translate Java SOAP requests to Perl using SOAP::Lite, but I am quite stuck this time
These are the SOAP functions in Java:
##Connecting to the WSDL file Public myService As DialogSearch.SearchService = New _ DialogSearch.Se +archService ##Creating a session object Public mySession As DialogSearch.SessionStruct = New _ DialogSearch.S +essionStruct ##Updating the object parameters mySession.Account = “123456” mySession.Password = “xyzabc” mySession.Cost = 0 mySession.State=”START_SESSION” mySession.Atomic = True mySession.Interupt = False ##Sending the object as input to the Version function Dim myResult As DialogSearch.StringResult = _ MyService.Version(mySession)
I haven't used Java for a while, but it seems that you need to connect the the WSDL page, create a "session" object, and then send it as input to a one of the SOAP functions. I tried doing the same in Perl, using a hash instead of an object:
use strict; use warnings; use SOAP::Lite+trace=> 'debug'; { ##Connecting to the SOAP API my $request = SOAP::Lite->service('http://searchapi2.dialog.com/ax +is/DialogSearch.wsdl'); ##The session object with parameters my $session = {}; $session->{Account} = 'account'; $session->{Password} = 'pass'; $session->{State} = 'START_SESSION'; $session->{Cost} = 0; $session->{Atomic} = 'True'; $session->{Interupt} = 'False'; $session->{ProcessID} = ''; ##Calling the version function my $result = $request->Version($session); }
When I run this program, I get this XML message:
<faultcode>soapenv:Server.userException</faultcode> <faultstring>org.xml.sax.SAXException: Deserializing parameter &apo +s;Session&apos;: could not find deserializer for type SessionStruct< +/faultstring>
I'm not sure exactly what this means,but my guess is that the Server tries to use the XML to create an object and fails. I tried using a Perl Module instead of a hash as the "session" object but with the same results.
Right now, if you run this and look at the XML that is created, all the parameters from the hash are sent. It should be OK, but something is missing.
The bottom line is that I seem to need an object in Perl that is bit more similar to an object in Java for the XML.
Any suggestions?
Thanks,
Guy Naamati (mrguy123)


For the children, they mark, and the children, they know The place where the sidewalk ends. --Shel Silverstein

In reply to SOAP::Lite:Java vs Perl by mrguy123

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.