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

O how i beg for your help.

for the past 3 days i have been trying to complete a soap request using soap::lite. i have read the docs, browsed the monestary and searched the internet and have still not been able to successfully send a valid request and receive a response.

below is the code i am trying to use to produce the xml request which i also show below.

any and all help as always is much appreciated.

xml trying to be created using soap::lite:
<?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope> <SOAP-ENV:Body> <typens:newAccount xmlns:typens="urn:HELP"> <primary xsi:type="typens:LoginInfo"> <username xsi:type="xsd:string">myusername</username> <password xsi:type="xsd:string">mypwd</password> + </primary> <securityid xsi:type="xsd:string">123456789</securityid> <personalinfo xsi:type="typens:PersonalInfo"> <pin xsi:type="xsd:string">1554</pin> <street xsi:type="xsd:string">123 test st</street> <contact xsi:type="xsd:string">John Down</contact> </personalinfo> </typens:newAccount> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
notice there are name spaces in the above xml. i cannot seem to be able to successfully create a call that is accepted by the server to mimic what is shown above. the code i am using (at least the current try) is:
$SendObject = SOAP::Lite -> service('https://mydomain.com/filname.wsdl') -> uri('https://mydomain.com/server.php'); $response = $SendObject -> newDomain( SOAP::Data->name('username' => ' +myusername'), SOAP::Data->name('password' => 'mwowd'), SOAP::Data->name('securityid' => '123456789'), SOAP::Data->name('pin' => '1554'), SOAP::Data->name('street' => '123 street'), SOAP::Data->name('contact' => 'John Doe') + );
==================UPDATE===================

you can biuld a raw xml message and send it using soap::lite as shown in the following snippet. this avoids the frustration i was running into using the soap object and seems to work for my case at least.

if there is an issue with this that someone is aware of please let me know.
my $xml = '<primary xsi:type="typens:LoginInfo"> <username xsi:type="xsd:string">myusername</username> <password xsi:type="xsd:string">mypwd</password> + </primary> <securityid xsi:type="xsd:string">123456789</securityid> <personalinfo xsi:type="typens:PersonalInfo"> <pin xsi:type="xsd:string">1554</pin> <street xsi:type="xsd:string">123 test st</street> <contact xsi:type="xsd:string">John Down</contact> </personalinfo>'; my $response= SOAP::Lite -> service('https://mydomain.com/service.wsdl') + -> outputxml(1) -> newAccount( SOAP::Data->type('xml' => $xml) ); print $response;
$response will contain the raw xml response from the service call and you will be able to parse that using XML::Simple or whatever you need to do with it.

Hope that helps someone.

Replies are listed 'Best First'.
Re: how to send a request with soap::lite
by jesuashok (Curate) on Jan 12, 2006 at 10:07 UTC
    Hi the below code may be useful for you.

    This is the example I used when I learnt to send XML request.

    <?xml version='1.0' ?> <env:Envelope xmlns:env="http://www.w3.org/2002/12/soap-envelope"> <env:Header></env:Header> <env:Body> <isbn:getTitle xmlns:isbn="http://www.nicholaschase.com/BookLook"> +0672324229</isbn:getTitle> </env:Body> </env:Envelope
    #!/usr/local/bin/perl use CGI qw/:standard :netscape/; use SOAP::Transport::HTTP; SOAP::Transport::HTTP::CGI -> dispatch_to('BookLook') -> handle; package BookLook; sub getTitle { my ($class, $isbn) = @_; if ($isbn == '0672324229'){ return "XML Primer Plus"; } else { return "Unknown"; } } sub getAllInfo { my ($class, $isbn) = @_; if ($isbn == '0672324229'){ return 'XML Primer Plus by Nicholas Chase, $32.58'; } else { return "Unknown"; } }
    Check If you find it useful for you.

    "Keep pouring your ideas"
      can you explain how it is generating the request? that is where i am getting confused. i don't understand how to use soap::lite so that it builds the proper request. thanks