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

Re: [soaplite] SOAP::Lite Server issues

Expand Messages
  • Duncan Cameron
    ... SOAP doesn t support passing objects back and forward. SOAP::Lite has bits of magic that allow it between SOAP::Lite clients and servers, but not with
    Message 1 of 2 , Jul 18, 2002
    • 0 Attachment
      On 2002-07-17 Curtis Poe wrote:
      >My apologies for this *somewhat* non-perl mailing.
      >
      >I have a SOAP::Lite server that works just fine. My SOAP::Lite Perl client
      >has no problem calling new() and then making method calls. However, the
      >actual client needs to be written in Python :( My coworker is using ZSI
      >(http://www.xmlhack.com/read.php?item=1572) for his Python SOAP client.
      >While my Perl code works, he can't seem to do anything with his. My code is
      >below:
      >
      > #!D:/perl/bin/perl.exe -w
      >
      > # This is the server
      >
      > use strict;
      > use SOAP::Transport::HTTP;
      >
      > SOAP::Transport::HTTP::CGI
      > -> dispatch_to( 'Temperatures' )
      > -> handle;
      >
      > package Temperatures;
      >
      > sub f2c {
      > my ( $self, $f, $format ) = @_;
      > my $fmt = $format || $self->{_format};
      > return sprintf $fmt, (5/9 * ($f - 32));
      > }
      >
      > sub c2f {
      > my ( $self, $c, $format ) = @_;
      > my $fmt = $format || $self->{_format};
      > return sprintf $fmt, (32 + $c*9/5);
      > }
      >
      > sub format {
      > my ( $self, $format ) = @_;
      > $self->{_format} = $format if $format;
      > $self->{_format};
      > }
      >
      > sub new {
      > my $class = shift;
      > bless {
      > _format => '%.2f'
      > }, $class;
      > }
      >
      >--------------
      >
      > #!D:/perl/bin/perl.exe -wT
      >
      > # This is the client
      > # I omitted the CGI HTML functions for clarity
      >
      > use strict;
      > use CGI qw/:standard/;
      > use SOAP::Lite +autodispatch =>
      > uri => 'http://192.168.1.26/Temperatures',
      > proxy => 'http://192.168.1.26/soap/temper.cgi';
      >
      > my $temp = param( 'temp' );
      > my $type = param( 'type' ) || '';
      > my $format = param( 'format' ) || '';
      >
      > $temp = '' if ! defined $temp;
      >
      > ($temp) = $temp =~ /([\d.]+)/;
      > ($type) = $type =~ /([cf])/;
      >
      > my $temp_result;
      >
      > if ( $temp ) {
      > my $temperature = Temperatures->new;
      > $temperature->format( $format ) if $format;
      > $temp_result = $type eq 'c'
      > ? $temperature->c2f( $temp )
      > : $temperature->f2c( $temp );
      > }
      >
      >Here's the XML response he gets when he calls new():
      >
      ><SOAP-ENV:Body>
      > <namesp1:newResponse xmlns:namesp1="http://192.168.1.26/Temperatures">
      > <Temperatures xsi:type="namesp1:Temperatures">
      > <_format xsi:type="xsd:string">%.2f</_format>
      > </Temperatures>
      > </namesp1:newResponse>
      ></SOAP-ENV:Body>
      >
      >Frankly, I have no idea where to look next. I've done a lot of Web
      >searching, but to no avail. Since I know nothing about SOAP, is it possible
      >that I am just totally misunderstanding the way things work? Is it not
      >possible for a Python client to call a Perl constructor via SOAP?

      SOAP doesn't support passing objects back and forward. SOAP::Lite has bits
      of 'magic' that allow it between SOAP::Lite clients and servers, but not with
      other implementations. Using autodispatch allows your perl client and server
      to pass objects between them.

      In your case, the SOAP::Lite server has sent back the contents of the hash
      returned by your new() call - just the field _format with a value of '%.2f'.
      It's then up to the Python client to decide what to do with that. I guess that
      you want it to treat the response as creating a Python Temparatures object
      and populating it, but I don't know how to do that!

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