#!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; } #### #!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 ); } #### <_format xsi:type="xsd:string">%.2f