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

Hello Every one, Looking for some help and will be great if some one can help on parsing soap lite response.
#!/usr/bin/perl use SOAP::Lite;# +trace => [ transport => sub { print $_[0]->as_string + } ]; $SOAP::Constants::PREFIX_ENV = "soapenv"; $SOAP::Constants::PREFIX_ENC = "soapenc"; my $soapRequest = SOAP::Lite -> uri('XXX') -> readable(1) -> ns('XXX') -> proxy('XXX'); my $Username = SOAP::Header->name('wsse:Username' => $username); my $Password = SOAP::Header->name('wsse:Password') ->attr({'Type'=>'http://docs.oasis-open.org +/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText +'}) ->value($password); my $UsernameToken = SOAP::Header->name('wsse:UsernameToken') ->value(\SOAP::Header->value($Username,$Passwo +rd)); my $security = SOAP::Header->name('wsse:Security') ->attr ({'soapenv:mustUnderstand'=>'1', 'xmlns:wsse' => 'http://docs.oasis-o +pen.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd' }) ->value(\SOAP::Header->value($UsernameToken)); my $bsvc_ID = SOAP::Data ->name('had:Proxy_User_Name') ->value('XXX'); my $bsvc_ID1 = SOAP::Data ->name('had:Proxy_Password') ->value('XXX'); my $Int_ID = SOAP::Data ->name('had:Authentication') ->value(\SOAP::Data->value($bsvc_ID,$bsvc_ID1) +); my $Employee_Reference = SOAP::Data ->name('had:Report_Parameters') ->value(\SOAP::Data->value($Int_ID)); my $params = SOAP::Data ->name('had:Execute_Report') ->value(\SOAP::Data->value($Employee_Reference +)); $soapRequest->call($params,$Employee_Reference,$security);
Above is my code which makes a SOAP call and returns me an output
<?xml version='1.0' encoding='UTF-8'?> <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"> <env:Body> <wd:Report_Data xmlns:wd="urn:com.workday.report/Hadoop_Master_Integration +_Event"> <wd:Report_Entry> <wd:Workday_ID>6c995364b0311079b40f3b5067d12175</wd:Wo +rkday_ID> </wd:Report_Entry> </wd:Report_Data> </env:Body> </env:Envelope>
Now what I want to do is pick 6c995364b0311079b40f3b5067d12175 from the soap result and use it in another soap call. I have read many forums but couldnt get conclusive answer. All I need 6c995364b0311079b40f3b5067d12175 into a variable which I can then use further?

Replies are listed 'Best First'.
Re: How to Parse SOAP::Lite response
by sharprez (Novice) on Oct 05, 2015 at 18:12 UTC
    This is how I did it... Not your code, but a worthy example.
    use XML::Parser; .... Build your request and get response.. ... my $response = $userAgent->request($request); Put the response in the XMLparser. my $ref = XMLin($response->content); my $secr = $ref->{'soapenv:Header'}->{'wsse:Security'}; print $secr;
    I hope that guides you. :)
Re: How to Parse SOAP::Lite response
by runrig (Abbot) on Oct 05, 2015 at 18:51 UTC
Re: How to Parse SOAP::Lite response
by Anonymous Monk on Oct 05, 2015 at 21:43 UTC