I don't know squat about SOAP. Now I've been asked to write SOAP servers in Perl (using SOAP::Lite) and having a Python client be able to interact with them. 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 for his Python SOAP client. While my Perl code works, he can't seem to do anything with his Python client.

This is my server code:

#!D:/perl/bin/perl.exe -w 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; }

And this is my client (I stripped out the HTML part). Notice that I appear to be instantiating a new Temperature object and then calling methods on it. However, my co-worker cannot do anything with the returned data.

#!D:/perl/bin/perl.exe -wT 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? If that's the case, does this mean that the Simple Object Access Protocol isn't really for accessing objects?

Note that if I recode everything in a functional style, Python has no problem communicating with my server.

Cheers,
Ovid

Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.


In reply to Using Perl's SOAP::Lite to talk to Python by Ovid

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.