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

how to use base64

Expand Messages
  • Dave Howorth
    Hello, I m trying to use base64 encoding. I figure that it is one possible solution to my previous issue of invalid tokens, and the doc says it may be faster
    Message 1 of 2 , Aug 18, 2006
    • 0 Attachment
      Hello,

      I'm trying to use base64 encoding. I figure that it is one possible
      solution to my previous issue of invalid tokens, and the doc says it may
      be faster as well. But I haven't figured out how to make it work...

      I'm trying to use the method suggested of adding:

      *SOAP::Serializer::as_string = \&SOAP::Serializer::as_base64;

      I've added that line in both my client and server setup. When I run a
      test, my client reports an error:

      --- SOAP:CLIENT FAULT ---
      Type 'base64' can't be found in a schema class 'SOAP::Serializer'
      at /home/dhoworth/tmp/SOAP/Lite.pm line 114

      (line number may be off slightly since I've added some debugging printout)

      The magic is pretty strong in SOAP::Lite, but as far as I can see by
      tracing, this error is actually produced by the server when it attempts
      to encode the response (which is an HTML fragment string returned by one
      of my methods).

      The error is produced by SOAP::XMLSchema1999::Serializer::AUTOLOAD which
      is attempting to load SOAP::Serializer::as_base64. It checks whether
      @SOAP::Serializer::EXPORT contains base64, but SOAP::Serializer's export
      list is empty.

      The response is encoded in the http://www.w3.org/2001/XMLSchema-instance
      namespace, so I'm guessing that somehow it should be finding
      SOAP::XMLSchema2001::Serializer::as_base64 and that class does indeed
      export base64.

      Which leads me to think that some inheritance initialization went wrong,
      so I probably forgot to do something, but I don't have the vaguest idea
      what :(

      I'm also confused as to whether it should be 'as_base64' or
      'as_base64Binary' - the CPAN docs don't exactly match the POD in the
      released code. But using either results in a similar error.

      Any help would be greatly appreciated.

      Thanks and regards,
      Dave
    • Dave Howorth
      ... As far as I can tell, the method proposed above as recommended in the POD doesn t work. It s beyond my skill and time to understand exactly what s going on
      Message 2 of 2 , Aug 22, 2006
      • 0 Attachment
        I wrote:
        > I'm trying to use base64 encoding. I figure that it is one possible
        > solution to my previous issue of invalid tokens, and the doc says it may
        > be faster as well. But I haven't figured out how to make it work...
        >
        > I'm trying to use the method suggested of adding:
        >
        > *SOAP::Serializer::as_string = \&SOAP::Serializer::as_base64;
        >
        > I've added that line in both my client and server setup. When I run a
        > test, my client reports an error:
        >
        > --- SOAP:CLIENT FAULT ---
        > Type 'base64' can't be found in a schema class 'SOAP::Serializer'
        > at /home/dhoworth/tmp/SOAP/Lite.pm line 114
        >
        > (line number may be off slightly since I've added some debugging printout)

        As far as I can tell, the method proposed above as recommended in the
        POD doesn't work. It's beyond my skill and time to understand exactly
        what's going on in SOAP::Lite but it appears that the above is fouled up
        by AUTOLOAD complexities.

        But I have managed to make SOAP::Lite encode everything as base64. On
        the server after:

        my $daemon = SOAP::Transport::HTTP::Daemon->new( ...args...);

        I added:

        my $serializer = $daemon->serializer;
        $serializer->typelookup->{fudge} =
        [ 9, sub { 1 }, 'as_base64Binary' ];

        On the client, after:

        use SOAP::Lite ...args...;

        I added:

        my $serializer = SOAP::Lite->serializer;
        $serializer->typelookup->{fudge} =
        [ 9, sub { 1 }, 'as_base64Binary' ];

        I think it would probably be better to completely replace the typelookup
        hash because SOAP::Lite appears to sort it every time it encodes a
        scalar :( But I haven't got that far yet.

        Using base64 does seem to solve my 'invalid token' problem.

        Cheers, Dave
      Your message has been successfully submitted and would be delivered to recipients shortly.