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

Re: [soaplite] Setting string types on map name and values

Expand Messages
  • Mental Patient
    ... Keep going the way you re going. my %h; $h{ type } = SOAP::Data- type( string = hms.phone.us ); $h{ action } = fix ; $h{ int } =
    Message 1 of 2 , Aug 20, 2003
    • 0 Attachment
      salatfelarov wrote:
      > Hi All -
      > I'm calling an Apache Axis service that takes a HashMap of String
      > name/value pairs. It looks like the SOAP::Lite autotyper is helping
      > me a bit too much since sometimes the values contain numeric values
      > that get converted to xsd:int.
      > Here's the Client Code:
      > my $service = SOAP::Lite
      > -> uri($serviceURI)
      > -> proxy($serviceProxy);
      > my $results = $service->setAttributeValues(
      > SOAP::Data->type(map =>\%nvPairs)->name("attributeNVPairs"));
      > This generates a request like so, where numeric string values are
      > autotyped to int - which ends up throwing a ClassCastException when
      > the underlying EJB hits an Integer in the inbound HashMap instead of
      > a String like it expects.
      > <attributeNVPairs xsi:type="apachens:Map>
      > <item>
      > <key xsi:type="xsd:string">String Parameter Key</key>
      > <value xsi:type="xsd:string">StringParameter Value</key>
      > </item>
      > <item>
      > <key xsi:type="xsd:string">Numeric String Parameter Key</key>
      > <value xsi:type="xsd:int">1</key>
      > </item>
      > </attributeNVPairs>
      > What I need is to be able to set the type for each key and value in
      > the map to string.
      > Any ideas?

      Keep going the way you're going.

      my %h;
      $h{'type'} = SOAP::Data->type('string' => "hms.phone.us");
      $h{'action'} = 'fix';
      $h{'int'} = SOAP::Data->type('int' => 1);
      $h{'string'} = '1 666 251 4432';
      $hr = $soap->call(one_shot=> SOAP::Data->type(map => \%h) )->result;

      that yeilds the xml:

      <c-gensym3 xsi:type="apachens:Map">
      <key xsi:type="xsd:string">int</key>
      <value xsi:type="xsd:int">1</value>
      <key xsi:type="xsd:string">action</key>
      <value xsi:type="xsd:string">fix</value>
      <key xsi:type="xsd:string">string</key>
      <value xsi:type="xsd:string">1 666 251 4432</value>
      <key xsi:type="xsd:string">type</key>
      <value xsi:type="xsd:string">hms.phone.us</value>

      Yes, the first call to SOAP::Data was redundant. I could have just made
      the one call to set the int, but you see where I'm going with this, no?


      Mental (Mental@...)

      "The Torah... The Gospels... The Koran...
      Each claimed as the infallible word of GOD.
      Misquoted, misinterpreted, misunderstood, and misapplied.
      Maybe that's why he doesn't do any more interviews." - sinfest.net


      GPG public key: http://www.neverlight.com/pas/Mental.asc
    Your message has been successfully submitted and would be delivered to recipients shortly.