Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re: SOAP::Lite Client - Read response header

by McA (Priest)
on Mar 26, 2013 at 10:05 UTC ( #1025483=note: print w/replies, xml ) Need Help??

in reply to SOAP::Lite Client - Read response header


I had to smile seeing that Anonymous Monk gave a snippet hopefully extracting information from Body while you asked for Header, but probably he wanted to test your transfer capabilities.

Here is my snippet in the hope it helps you:

#!/usr/bin/perl use strict; use warnings; use Data::Dumper; use local::lib 'lib1'; use SOAP::Lite; my $xml = q{<?xml version="1.0" encoding="utf-8"?> <soapenv:Envelope xmlns:soapenv=" +nvelope/" xmlns:xsd="" xmlns:xsi="htt +p://"> <soapenv:Header> <ns1:sessionID soapenv:actor=" +oap/actor/next" soapenv:mustUnderstand="0" href="#id0" xmlns:ns1="htt +p://"/> </soapenv:Header> <soapenv:Body> <ns2:initExportDeviceResponse soapenv:encodingStyle="http: +//" xmlns:ns2=" +/netcontrol/ws/"> <initExportDeviceReturn href="#id1"/> </ns2:initExportDeviceResponse> <multiRef id="id0" soapenc:root="0" soapenv:encodingStyle= +"" xsi:type="soapenc:long" x +mlns:soapenc="">-91025392591 +2285490</multiRef> <multiRef id="id1" soapenc:root="0" soapenv:encodingStyle= +"" xsi:type="ns3:WSContext" +xmlns:ns3="" xmlns:soapenc="htt +p://"> <contextId xsi:type="soapenc:string">ContextId_1364228 +178892</contextId> <contextType xsi:type="soapenc:string">Export_Device</ +contextType> <filter xsi:type="soapenc:string">DeviceType='NAS'</fi +lter> <firstResultPos href="#id2"/> <internalResultCount href="#id3"/> <maxResults href="#id4"/> <options xsi:type="soapenc:string" xsi:nil="true"/> <query xsi:type="soapenc:string">SELECT DISTINCT huge- +ass sql statement cropped for clarity) ) ) ) ) ORDER BY 1</query> <resultCount href="#id5"/> </multiRef> <multiRef id="id4" soapenc:root="0" soapenv:encodingStyle= +"" xsi:type="xsd:int" xmlns: +soapenc="">5000</multiRef> <multiRef id="id3" soapenc:root="0" soapenv:encodingStyle= +"" xsi:type="xsd:int" xmlns: +soapenc="">0</multiRef> <multiRef id="id5" soapenc:root="0" soapenv:encodingStyle= +"" xsi:type="xsd:int" xmlns: +soapenc="">152</multiRef> <multiRef id="id2" soapenc:root="0" soapenv:encodingStyle= +"" xsi:type="xsd:int" xmlns: +soapenc="">0</multiRef> </soapenv:Body> </soapenv:Envelope> }; my $som = SOAP::Deserializer->deserialize($xml); my $subsom = $som->match('/Envelope/Header/[1]'); my $res = $subsom->valueof(); print "Result: $res\n";


Replies are listed 'Best First'.
Re^2: SOAP::Lite Client - Read response header
by sojourner9 (Initiate) on Mar 26, 2013 at 13:36 UTC

    That definitely works if I can get at the raw XML response from the server. Which is what I posted and you used for $xml.

    However, I should have been a bit clearer in my initial post. The XML response I posted above was captured via a tcpdump. The problem I'm getting is that when I use SOAP::Lite and print the results via Dumper, I'm only seeing the value in the body. So it looks like SOAP::Lite may be stripping the header off before I can get access to it.

    Using the same code as from the first post, this is the what I see from the dumper printout

    $VAR1 = bless( { 'resultCount' => '152', 'options' => undef, 'query' => 'SELECT DISTINCT huge-ass sql statement', 'filter' => 'DeviceType=\'NAS\'', 'maxResults' => '5000', 'firstResultPos' => '0', 'contextId' => 'ContextId_1364302533581', 'contextType' => 'Export_Device', 'internalResultCount' => '0' }, 'WSContext' );

    So, I'm thinking there needs to be something changed in these two lines in order to read the header (Or else, I need to do this with some completely different method) - just not sure what

    ## MAKE THE CALL, PRINT THE RESULTS my $client = SOAP::Lite ->service($WSDL); my $result = $client->initExportDevice($filter);


      I don't have the possibility to test this. But as far as I see in the docs $result should be a SOAP::SOM and you should be able to call the methods ob this class. There are three intersting ones: root, envelope, header.

      Sorry, I can't prove it.


        Sorry, I can't prove it.

        :) I'm too tired to even try

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1025483]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2018-05-21 23:06 GMT
Find Nodes?
    Voting Booth?