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

Re: Sending a hash to java

Expand Messages
  • tmangner
    ok, i got the same problem as jboy55 ... and i tried duncans suggestion. that works fine, as long as the hash is a very simple one. but my hash is somewhat
    Message 1 of 4 , Aug 9, 2002
    • 0 Attachment
      ok, i got the same problem as jboy55 ... and i tried duncans
      suggestion. that works fine, as long as the hash is a very simple one.

      but my hash is somewhat more complex. there are arrayrefs and other
      hashrefs as values of the actual hash ...

      so java stills murns about "No mapping found
      for 'http://xml.apache.org/xml-soap:SOAPStruct' using encoding
      style 'http://schemas.xmlsoap.org/soap/encoding/'."

      can anyone give me a hint. how to encode a complex hash, so that java
      will accept it as a construct of hashtables and arrays???

      thanks in advance
      torsten

      --- In soaplite@y..., Duncan Cameron <dcameron@b...> wrote:
      > On 2002-03-29 jboy55 wrote:
      > >Ok,
      > >
      > >I'm frustrated that this just isn't working. And I can't find a
      clear
      > >example in any of the documentation.
      > >
      > >i have a function on Java that looks like
      > >
      > >sendCart(String id, HashTable cart);
      > >
      > >so i try
      > >my $soap1 = SOAP::Lite
      > > -> uri('urn:ServiceProxy')
      > > -> proxy('http://localhost:8088/soap/servlet/rpcrouter');
      > >
      > >$id = SOAP::Data->type(string => '1221');
      > >result = $soap1->sendCart($id, \%hash);
      > >
      > >and i get this error
      > >
      > >SOAP-ENV:Client, No Deserializer found to deserialize
      > >a 'http://xml.apache.org/xml-soap:SOAPStruct' using encoding
      > >style 'http://schemas.xmlsoap.org/soap/encoding/'.
      > >
      > >
      > >I shouldn't be pulling my hair out over this... this MUST be
      simple.
      > >
      > >What's going on?
      > >
      > It's not well documented but I think that you want to try the 'map'
      type:
      >
      > $result = $soap1->sendCart(
      > $id,
      > SOAP::Data->type(map => \%hash)->name('cart')
      > );
      >
      > This should generate an xml element something like:
      > <cart xsi:type="xmlsoap:Map"> which should be handled by the
      default Apache
      > Java serializers to produce a hashtable.
      >
      > Regards,
      > Duncan Cameron
    • Duncan Cameron
      ... If you want _all_ hashes serialised as maps then you can redefine SOAP::Lite s internal methods with something like this: *SOAP::Serializer::encode_hash =
      Message 2 of 4 , Aug 11, 2002
      • 0 Attachment
        On 2002-08-09 tmangner wrote:
        >ok, i got the same problem as jboy55 ... and i tried duncans
        >suggestion. that works fine, as long as the hash is a very simple one.
        >
        >but my hash is somewhat more complex. there are arrayrefs and other
        >hashrefs as values of the actual hash ...
        >
        >so java stills murns about "No mapping found
        >for 'http://xml.apache.org/xml-soap:SOAPStruct' using encoding
        >style 'http://schemas.xmlsoap.org/soap/encoding/'."
        >
        >can anyone give me a hint. how to encode a complex hash, so that java
        >will accept it as a construct of hashtables and arrays???
        >
        >thanks in advance
        >torsten
        >
        >--- In soaplite@y..., Duncan Cameron <dcameron@b...> wrote:
        >> On 2002-03-29 jboy55 wrote:
        >> >Ok,
        >> >
        >> >I'm frustrated that this just isn't working. And I can't find a
        >clear
        >> >example in any of the documentation.
        >> >
        >> >i have a function on Java that looks like
        >> >
        >> >sendCart(String id, HashTable cart);
        >> >
        >> >so i try
        >> >my $soap1 = SOAP::Lite
        >> > -> uri('urn:ServiceProxy')
        >> > -> proxy('http://localhost:8088/soap/servlet/rpcrouter');
        >> >
        >> >$id = SOAP::Data->type(string => '1221');
        >> >result = $soap1->sendCart($id, \%hash);
        >> >
        >> >and i get this error
        >> >
        >> >SOAP-ENV:Client, No Deserializer found to deserialize
        >> >a 'http://xml.apache.org/xml-soap:SOAPStruct' using encoding
        >> >style 'http://schemas.xmlsoap.org/soap/encoding/'.
        >> >
        >> >
        >> >I shouldn't be pulling my hair out over this... this MUST be
        >simple.
        >> >
        >> >What's going on?
        >> >
        >> It's not well documented but I think that you want to try the 'map'
        >type:
        >>
        >> $result = $soap1->sendCart(
        >> $id,
        >> SOAP::Data->type(map => \%hash)->name('cart')
        >> );
        >>
        >> This should generate an xml element something like:
        >> <cart xsi:type="xmlsoap:Map"> which should be handled by the
        >default Apache
        >> Java serializers to produce a hashtable.
        >>
        >> Regards,
        >> Duncan Cameron
        If you want _all_ hashes serialised as maps then you can redefine
        SOAP::Lite's internal methods with something like this:

        *SOAP::Serializer::encode_hash = \&SOAP::Serializer::as_map;

        It causes a '... redefined' warning but otherwise seems to work.

        The other way is to explicitly type each hash that you want
        serialised as a map as shown above. You might also be able to bless
        each hash into your own class and then provide a serialiser for
        that class which produces a map. Somehting like this:

        package myType;

        sub new {
        my ($class, $value) = @_;
        bless $value, $class;
        }

        package main;

        sub SOAP::Serializer::as_myType {
        shift->as_map(@_);
        }

        my $h1 = myType->new({ ...});

        Not sure how you want arrays to be serialised but I would guess that
        the same approach would apply.

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