Loading ...
Sorry, an error occurred while loading the content.

So fustrated returning hash that does not match XML results???

Expand Messages
  • dustintodd
    I am trying to accessing the XML results below. I expected the results to be array of hashes based on my reading. But it appears to be a hash of hashes. I have
    Message 1 of 2 , Mar 5, 2005
    • 0 Attachment
      I am trying to accessing the XML results below. I expected the results
      to be array of hashes based on my reading. But it appears to be a hash
      of hashes. I have include the raw XML results, a portion of the code
      I use to access it and the program run results. I have tried a number
      of different approaches and example code without getting the results I
      want. Can anyone see what I am doing wrong?

      - Dustin -

      <?xml version="1.0" encoding="UTF-8"?>
      <soapenv:Envelope
      xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <soapenv:Body>
      <ns1:getTableMetadataResponse
      soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:ns1="urn:com.cisco.nm.wlse.xmlapi.inventory">
      <getTableMetadataReturn xsi:type="ns1:TableMetadata">
      <columns xsi:type="ns1:TableColumn">
      <name xsi:type="xsd:string">CWVLWLANNUCASTKEYINDEX</name>
      <type xsi:type="xsd:string">INTEGER</type>
      </columns>
      <columns xsi:type="ns1:TableColumn">
      <name xsi:type="xsd:string">CWVLWLANNUCASTKEYLEN</name>
      <type xsi:type="xsd:string">INTEGER</type>
      </columns>
      <columns xsi:type="ns1:TableColumn">
      <name xsi:type="xsd:string">CWVLWLANNUCASTKEYVALUE</name>
      <type xsi:type="xsd:string">VARCHAR</type>
      </columns>
      <columns xsi:type="ns1:TableColumn">
      <name xsi:type="xsd:string">VLANID</name>
      <type xsi:type="xsd:string">INTEGER</type>
      </columns>
      </getTableMetadataReturn>
      </ns1:getTableMetadataResponse>
      </soapenv:Body>
      </soapenv:Envelope>


      Code to print out results

      my $tablemeta = SOAP::Lite
      -> proxy('http://XXXX:XXXXXX@10.1.1.9:1741/services/Inventory')
      -> uri('urn:com.cisco.nm.wlse.xmlapi.inventory')
      -> on_debug(sub{print@_})
      -> getTableMetadata($tlisting);

      if ($tablemeta->fault) {
      print $tablemeta->faultcode, " ", $tablemeta->faultstring, "\n",
      $tablemeta->faultdetail, "\n";
      } else {
      my $tablemetawork = $tablemeta->result;
      for my $k1 ( keys %$tablemetawork ) {
      print "k1: $k1\n";
      for my $k2 ( keys %{$tablemetawork->{ $k1 }} ) {
      print "$k1: $k2 $tablemetawork->{ $k1 }{ $k2 }\n";
      }
      }
      }


      Portion of output
      k1: columns
      columns: name VLANID
      columns: type INTEGER
    • Duncan Cameron
      ... I take it that you are not using S::L 0.65, where this issue has been addressed. This is how Data::Dumper shows the element $VAR1
      Message 2 of 2 , Mar 6, 2005
      • 0 Attachment
        On 2005-03-06 at 05:42:36 dustintodd wrote:

        >I am trying to accessing the XML results below. I expected the
        >results
        >to be array of hashes based on my reading. But it appears to be a
        >hash
        >of hashes. I have include the raw XML results, a portion of the code
        >I use to access it and the program run results. I have tried a
        >number
        >of different approaches and example code without getting the results
        >want. Can anyone see what I am doing wrong?
        >
        >- Dustin -
        I take it that you are not using S::L 0.65, where this issue has been
        addressed. This is how Data::Dumper shows the
        <getTableMetadataReturn> element

        $VAR1 = bless( {
        'columns' => [
        bless( {
        'type' => 'INTEGER',
        'name' => 'CWVLWLANNUCASTKEYINDEX'
        }, 'TableColumn' ),
        bless( {
        'type' => 'INTEGER',
        'name' => 'CWVLWLANNUCASTKEYLEN'
        }, 'TableColumn' ),
        bless( {
        'type' => 'VARCHAR',
        'name' => 'CWVLWLANNUCASTKEYVALUE'
        }, 'TableColumn' ),
        bless( {
        'type' => 'INTEGER',
        'name' => 'VLANID'
        }, 'TableColumn' )
        ]
        }, 'TableMetadata' );

        If you cannot upgrade to 0.65 then you will need to use an approach
        like this:

        my $som = $soap->getTableMetadata($tlisting);
        my @columns = $som->match('//columns')->valueof;
        for my $column (@columns) {
        print "$column->{name} $column->{type}\n";
        }


        Duncan
      Your message has been successfully submitted and would be delivered to recipients shortly.