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

Re: How do I create Apache Map type

Expand Messages
  • robertsumca
    A follow up question on this. If I have a nested hash likes this my %hash = ( PROFILES = { ADDRESS2 = #20 , STATEORPROVINCE = CA . COUNTRY
    Message 1 of 3 , Nov 27, 2002
    • 0 Attachment
      A follow up question on this. If I have a nested hash likes this

      my %hash = (
      PROFILES =>
      { ADDRESS2 => '#20',
      STATEORPROVINCE => 'CA'.
      COUNTRY => 'US'
      }
      );

      Can I get an output from SOAP::Lite which likes the xml fragment
      listed below. The main part is that the nested hashes become a
      different xml segment instead of being nested underneath the parent
      key. In the sample PROFILES has a href instead of having nested
      children listing the individual <item><key><value> sets.

      thanks,
      Robert


      <multiRef id="id0" SOAP-ENC:root="0" xsi:type="ns2:Map"
      xmlns:ns2="http://xml.apache.org/xml-soap">
      <item>
      <key xsi:type="xsd:string">PROFILES</key>
      <value href="#id1"/>
      </item>
      </multiRef>
      <multiRef id="id1" SOAP-ENC:root="0" xsi:type="ns3:Map"
      xmlns:ns3="http://xml.apache.org/xml-soap">
      <item>
      <key xsi:type="xsd:string">ADDRESS2</key>
      <value xsi:type="xsd:string">#20</value>
      </item>
      <item>
      <key xsi:type="xsd:string">STATEPROVINCE</key>
      <value xsi:type="xsd:string">CA</value>
      </item>
      <item>
      <key xsi:type="xsd:string">COUNTRY</key>
      <value xsi:type="xsd:string">US</value>
      </item>

      </multiRef>



      --- In soaplite@y..., Duncan Cameron <dcameron@b...> wrote:
      > On 2002-11-27 robertsumca wrote:
      > >I have question regarding serializer. I want to convert a perl
      > >hash into the following output. The has is defined as follows
      > >my %hash = (USER_ID => 24875227,
      > > EMAIL => 'someone@h...',
      > > PROFILES => 'NEW');
      > >
      > ><multiRef id="id1" SOAP-ENC:root="0"
      > > xsi:type="ns3:Map"
      > > xmlns:ns3="http://xml.apache.org/xml-soap"
      > > xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
      > > <item>
      > > <key xsi:type="xsd:string">USER_ID</key>
      > > <value xsi:type="xsd:decimal">24875227</value>
      > > </item>
      > > <item>
      > > <key xsi:type="xsd:string">EMAIL</key>
      > > <value xsi:type="xsd:string">someone@h...</value>
      > > </item>
      > > <item>
      > > <key xsi:type="xsd:string">PROFILES</key>
      > > <value xsi:type="xsd:string">NEW </value>
      > > </item>
      > ></multiRef>
      > >
      > >
      > >The type of multiRef element is Map, which I think is defined in
      the
      > >apache/xml-soap namespace. Is there a standard serialzer which
      can
      > >do this
      >
      > Yes, funnily enough the 'map' type. Try this:
      > SOAP::Data->type(map => \%hash)->name('hash')
      >
      > It produces a sequence of item elements, each with pairs of
      key/value
      > elements.
      >
      > Regards,
      > Duncan Cameron
    Your message has been successfully submitted and would be delivered to recipients shortly.