Thread

Posted on Wed May 23 14:55:48 2007 by tiredstudent
basic pattern matching problem
Hi! I have spent too many hours trying to work this out. Can anyone help? I'm simply trying to set up two simple operations on a SOAP::Lite server. I need to convert an input string to upper case if any lower case characters are found. The second operation needs to perform the opposite: convert a string to lower case if upper case characters found. Here's the code:
use SOAP::Lite; use SOAP::Transport::HTTP ; my $port = shift ; my $soapServer = SOAP::Transport::HTTP::Daemon -> new (LocalPort => $port ) -> dispatch_to ( qw(echoString) ) -> on_action ( sub { die "SOAPAction should be \"http://soapinterop.org/\"\n" unless $_[0] eq '"http://soapinterop.org/"';} ) ; print "Starting SOAP server on URL: ".$soapServer->url."\n" ; $soapServer->handle; sub echoString { # Receives a string and echoes it back my ($class, $inputString) = @_ ; die "no input provided\n" if !$inputString ; $inputString =~ tr/A-Z/a-z/ if $inputString =~ m/[A-Z]/ ; $inputString =~ tr/a-z/A-Z/ if $inputString =~ m/[a-z]/ ; return SOAP::Data->name('return')->type('string')->value($inputString); }
The code gives the following error on the command line: Use of uninitialized value in pattern match (m//) at /usr/local/lib/perl5/site_perl/5.8.0/SOAP/Lite.pm line 429. proxy: transport protocol not specified Any help would be much appreciated! :)
Direct Responses: 5239 | Write a response
Posted on Mon May 28 14:37:17 2007 by saramic in response to 5211
Re: basic pattern matching problem
what version of SOAP::Lite are you using? in 0.69 line 429 is
sub splitlongname { local($1,$2); $_[0] =~ /^(?:\{(.*)\})?(.+)$/; return ($1,$2) }
I tried this on my windows box and seemed to run OK once I fixed a few things to actually do what you want it to do. I did not get your mis-match error at all? changes to your server code, I can not remember how to get away without the uri#action like notation at the moment
die "SOAPAction should be \"http://soapinterop.org/\"\n" unless $_[0] eq '"http://soapinterop.org/#echoString"';
the logic in your code would change everything to uppercase.
if ($inputString =~ m/[A-Z]/) { $inputString =~ tr/A-Z/a-z/ } elsif ( $inputString =~ m/[a-z]/ ) { $inputString =~ tr/a-z/A-Z/ }
this is what I tested with
my $result = SOAP::Lite -> uri('http://soapinterop.org/') -> proxy('http://localhost:8888/') -> echoString('THIS IS GREAT'); unless ($result->fault) { print $result->result(); } else { print join ', ', $result->faultcode, $result->faultstring; } print "\n"; print SOAP::Lite -> uri('http://soapinterop.org/') -> proxy('http://localhost:8888/') -> echoString('this is great') -> result;
you may find some more details here http://www.soaplite.com/ cheers Michael
Write a response