Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: SOAP::Lite Client - Read response header

by McA (Curate)
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

Hi,

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="http://schemas.xmlsoap.org/soap/e +nvelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="htt +p://www.w3.org/2001/XMLSchema-instance"> <soapenv:Header> <ns1:sessionID soapenv:actor="http://schemas.xmlsoap.org/s +oap/actor/next" soapenv:mustUnderstand="0" href="#id0" xmlns:ns1="htt +p://xml.apache.org/axis/session"/> </soapenv:Header> <soapenv:Body> <ns2:initExportDeviceResponse soapenv:encodingStyle="http: +//schemas.xmlsoap.org/soap/encoding/" xmlns:ns2="http://diamondip.com +/netcontrol/ws/"> <initExportDeviceReturn href="#id1"/> </ns2:initExportDeviceResponse> <multiRef id="id0" soapenc:root="0" soapenv:encodingStyle= +"http://schemas.xmlsoap.org/soap/encoding/" xsi:type="soapenc:long" x +mlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">-91025392591 +2285490</multiRef> <multiRef id="id1" soapenc:root="0" soapenv:encodingStyle= +"http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns3:WSContext" +xmlns:ns3="http://service.ipcontrol.diamondip.com" xmlns:soapenc="htt +p://schemas.xmlsoap.org/soap/encoding/"> <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= +"http://schemas.xmlsoap.org/soap/encoding/" xsi:type="xsd:int" xmlns: +soapenc="http://schemas.xmlsoap.org/soap/encoding/">5000</multiRef> <multiRef id="id3" soapenc:root="0" soapenv:encodingStyle= +"http://schemas.xmlsoap.org/soap/encoding/" xsi:type="xsd:int" xmlns: +soapenc="http://schemas.xmlsoap.org/soap/encoding/">0</multiRef> <multiRef id="id5" soapenc:root="0" soapenv:encodingStyle= +"http://schemas.xmlsoap.org/soap/encoding/" xsi:type="xsd:int" xmlns: +soapenc="http://schemas.xmlsoap.org/soap/encoding/">152</multiRef> <multiRef id="id2" soapenc:root="0" soapenv:encodingStyle= +"http://schemas.xmlsoap.org/soap/encoding/" xsi:type="xsd:int" xmlns: +soapenc="http://schemas.xmlsoap.org/soap/encoding/">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";

McA


Comment on Re: SOAP::Lite Client - Read response header
Download Code
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);

      Hi,

      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.

      McA

        Sorry, I can't prove it.

        :) I'm too tired to even try

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1025483]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2014-09-23 07:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (210 votes), past polls