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

Dear Monks, I am completely new to SOAP and trying to write a client for a web service our company intend to use.



My problem is that i am not able to figure out why this code does not fill up $response. I am pasting my code..

my $webService = SOAP::Lite-> uri($self->{NAMESPACE}) -> on_action(sub{sprintf '%s/%s', @_ }) -> outputxml("1") -> proxy($self->{ENDPOINT}); eval{ my $response = $webService ->call(SOAP::Data->name("SubmitXml")->attr({xmlns => $self->{NAM +ESPACE}}), SOAP::Data->name(Profile => $self->{HAP})->type('string') +, SOAP::Data->name(Request => $xmlRequest)->type('xml'), SOAP::Data->name(Filter => $xmlFilter)->type('xml')); }; if($@){print $@} open RES,">>Responce.log"; if (defined $response) { print RES $response."\n"; }else {print RES "========No Response======== \n";} close RES;

but i can see the proper response if i enable +trace on it shows me the right result but does not return it . please help me as I always end up with undefined $response.
i tried this $response=$webService->result; but the wsdl raised error saying that it does not expect this method,which was recorded in the log


This is server response seen in trace output as displayed on screen.
SOAP::Transport::HTTP::Client::send_receive: HTTP/1.1 200 OK Connection: close Date: Wed, 21 Jun 2006 10:44:06 GMT Server: Apache-Coyote/1.1 Content-Length: 4059 Content-Type: text/xml;charset=utf-8 Client-Date: Wed, 21 Jun 2006 10:45:18 GMT Client-Response-Num: 1 Client-SSL-Cert-Issuer: /O=VeriSign Trust Network/OU=VeriSign, Inc./OU +=VeriSign International Server CA - Class 3/OU=www.verisign.com/CPS I +ncorp.by Ref. LIABILITY LTD.(c)97 VeriSign Client-SSL-Cert-Subject: /C=US/ST=New Jersey/L=Parsippany/O=Cendant Co +rporation/OU=Terms of use at www.verisign.com/OU=Terms of use at www. +verisign.com/rpa (c)00/CN=copyws.cendant.com Client-SSL-Cipher: AES256-SHA Client-SSL-Warning: Peer certificate not verified <?xml version="1.0" encoding="UTF-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envel +ope/" xmlns:xsd="http://www.w3.org/1999/XMLSchema" xmlns:xsi="http:// +www.w3.org/1999/XMLSchema-instance"> <soapenv:Body> <SubmitXmlResponse xmlns=""> <SubmitXmlResult> <AirAvailability_6_2 xmlns=""><AirAvail><MoreToken><Tok>3 +01030383628882023605530276080</Tok></MoreToken><AvailSummary><NumSegs +>2</NumSegs></AirAvail></AirAvailability_6_2> </SubmitXmlResult> </SubmitXmlResponse> </soapenv:Body></soapenv:Envelope>

now according to me the $response should have this string as i have enabled the outputxml(1) .

Replies are listed 'Best First'.
Re: About SOAP ::Client written by me
by shmem (Chancellor) on Jun 21, 2006 at 12:08 UTC
    Your $response is lexically scoped in the eval block.

    say

    my $response; eval { $response = ... }
    or
    my $response = eval { $webService->call(); };
    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}

      oops!
      Thanks for the reply . I added that block later on and completly forgot abt it after some time.
      thank you very much.