[23039] in Perl-Users-Digest
Perl-Users Digest, Issue: 5259 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 22 18:10:37 2003
Date: Tue, 22 Jul 2003 15:10:13 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 22 Jul 2003 Volume: 10 Number: 5259
Today's topics:
Soap::Lite and hashes <SaschaMoe@web.de>
Re: Soap::Lite and hashes <aa@ukrecscuba.org.uk>
Re: Soap::Lite and hashes (Tad McClellan)
Re: Soap::Lite and hashes <SaschaMoe@web.de>
Re: Soap::Lite and hashes <aa@ukrecscuba.org.uk>
Re: Soap::Lite and hashes <SaschaMoe@web.de>
Re: Soap::Lite and hashes <aa@ukrecscuba.org.uk>
Re: theory vs practice ceases power <xaonon@hotpop.com>
Re: Using 'my' within nested loops <spamblock@junkmail.com>
Wide character <cms@may.be>
Re: Wide character (Thomas M. Widmann)
Re: <bwalton@rochester.rr.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 22 Jul 2003 22:58:04 +0200
From: Sascha Moellering <SaschaMoe@web.de>
Subject: Soap::Lite and hashes
Message-Id: <bfk1fe$dtc$02$1@news.t-online.com>
Hi,
I`ve a Hashtable containing several Hashtables and I want to send this to a
server using SOAP::Lite, but the problem is that I don`t know how to
serialize and deserialize the data. Example Data:
%hash = {`1` => {id => `sdf`, user => `asd`}, `2` => {id => `wer`, user =>
`aqwe`}}
Thank you,
Sascha
------------------------------
Date: 22 Jul 2003 19:40:51 GMT
From: Alasdair Allan <aa@ukrecscuba.org.uk>
Subject: Re: Soap::Lite and hashes
Message-Id: <bfk403$ehksl$1@ID-188041.news.uni-berlin.de>
Sascha Moellering wrote:
> I`ve a Hashtable containing several Hashtables and I want to send this to
> a server using SOAP::Lite, but the problem is that I don`t know how to
> serialize and deserialize the data...
Well you can just do it this way...
Sending,
my $soap = new SOAP::Lite();
$soap->uri( $urn );
$soap->proxy( $endpoint );
eval { $result = $soap->method( %hash ); };
if ( $@ ) {
print "Error: $@";
exit;
}
unless ( $result->fault() ) {
print "Result: " . $result->result() . "\n";
} else {
print "Fault: " . $result->faultstring() . "\n";
}
and then recieving,
sub method {
my $self = shift;
my %hash = @_;
foreach my $key ( sort keys % hash ) {
print "$key = $hash{$key}\n";
}
return SOAP::Data->name('return', 'ACK')->type('xsd:string');
}
I'm not sure why you're trying to concern yourself with serialisaton and
deserialisation? Are you calling an RPC style service, or a document
literal style service? If its an RPC style serice the above code will
do what you want, and SOAP::Lite will take care of the messy details for
you...
Al.
------------------------------
Date: Tue, 22 Jul 2003 15:08:41 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Soap::Lite and hashes
Message-Id: <slrnbhr6e9.1lg.tadmc@magna.augustmail.com>
Sascha Moellering <SaschaMoe@web.de> wrote:
> %hash = {`1` => {id => `sdf`, user => `asd`}, `2` => {id => `wer`, user =>
> `aqwe`}}
That is not Perl code.
If it was intended to be, then it has missed the mark with _multiple_
syntax errors.
If you expect people to help you the least you can do is ensure
that the question is accurate.
Have you seen the Posting Guidelines that are posted here frequently?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 23 Jul 2003 01:10:19 +0200
From: Sascha Moellering <SaschaMoe@web.de>
Subject: Re: Soap::Lite and hashes
Message-Id: <bfk97d$48d$05$1@news.t-online.com>
Alasdair Allan wrote:
...
> I'm not sure why you're trying to concern yourself with serialisaton and
> deserialisation? Are you calling an RPC style service, or a document
> literal style service? If its an RPC style serice the above code will
> do what you want, and SOAP::Lite will take care of the messy details for
> you...
>
Hi,
I tried the following, but there is still an error:
Client:
my $soap = new SOAP::Lite();
$soap->uri( $urn );
$soap->proxy( $endpoint );
my %hash = {"one" => "1", "two" => "2"};
eval {
my $result = $soap->soapTest( %hash );
};
if ( $@ ) {
print "Error: $@";
exit;
}
Server:
SOAP::Transport::HTTP::CGI
-> dispatch_to('Demo')
-> handle;
package Demo;
sub soapTest
{
my $self = shift;
my (%hash) = @_;
my $str;
foreach my $key(keys %hash){
print "$key = $hash{$key}\n";
#$str = $str.$key." => ".($hash{$key})."\n";
}
#return $str;
}
Error:
[Wed Jul 23 01:03:20 2003] [error] [client 127.0.0.1] malformed header from
script. Bad header=HASH(0x807e1c0) = : server.cgi
The soap-body looks a bit strange:
...
<SOAP-ENV:Body>
<namesp1:soapTest xmlns:namesp1="http://localhost/Demo">
<c-gensym3 xsi:type="xsd:string">HASH(0x807e1c0)</c-gensym3>
<c-gensym5 xsi:null="1"/>
</namesp1:soapTest>
</SOAP-ENV:Body>
...
Thank you,
Sascha
------------------------------
Date: 22 Jul 2003 21:13:58 GMT
From: Alasdair Allan <aa@ukrecscuba.org.uk>
Subject: Re: Soap::Lite and hashes
Message-Id: <bfk9em$fdt5v$1@ID-188041.news.uni-berlin.de>
Tad McClellan wrote:
> Sascha Moellering wrote:
> > %hash = {`1` => {id => `sdf`, user => `asd`},
> > `2` => {id => `wer`, user => `aqw`}}
>
> That is not Perl code. If it was intended to be, then it has missed the
> mark with _multiple_ syntax errors. If you expect people to help you the
> least you can do is ensure that the question is accurate.
Thats a bit harsh, its obvious that he wants a hash of hashes, and there
is only one (not multiple) syntax errors. The exterior brackets around the
hash should be () not {}, the following code works just fine for instance,
my %hash = ( '1' => { 'id' => 'sdf', 'user' => 'asd' },
'2' => { 'id' => 'wer', 'user' => 'aqw' } );
for my $i ( sort keys %hash ) {
print "User $i\n";
for my $j ( sort keys %{$hash{$i}} ) {
print " $j = " . ${$hash{$i}}{$j} . "\n";
}
}
the lack of trailing semi-colon on his code line is of course totally
allowed, its the only line (hence the last line) of code and so doesn't
need one.
Al.
------------------------------
Date: Wed, 23 Jul 2003 01:13:59 +0200
From: Sascha Moellering <SaschaMoe@web.de>
Subject: Re: Soap::Lite and hashes
Message-Id: <bfk9e8$48d$05$2@news.t-online.com>
Tad McClellan wrote:
> Sascha Moellering <SaschaMoe@web.de> wrote:
>
>> %hash = {`1` => {id => `sdf`, user => `asd`}, `2` => {id => `wer`, user
>> => `aqwe`}}
>
>
> That is not Perl code.
I know, it is supposed to be pseudo-code. Sorry.
Sascha
------------------------------
Date: 22 Jul 2003 21:30:41 GMT
From: Alasdair Allan <aa@ukrecscuba.org.uk>
Subject: Re: Soap::Lite and hashes
Message-Id: <bfkae1$fjmbr$1@ID-188041.news.uni-berlin.de>
Sascha Moellering wrote:
> Alasdair Allan wrote:
> > I'm not sure why you're trying to concern yourself with serialisaton
> > and deserialisation...
>
> I tried the following, but there is still an error...
You've got some errors, try the following,
--- Client.pl ---
use SOAP::Lite;
my $urn = "urn:/Demo";
my $endpoint = "http://127.0.0.1:8000";
my $soap = new SOAP::Lite();
$soap->uri( $urn );
$soap->proxy( $endpoint );
my %hash = ( "one" => "1", "two" => "2" );
eval {
my $result = $soap->soapTest( %hash );
};
if ( $@ ) {
print "Error: $@";
exit;
}
-----------------
and the server,
--- Server.pl ---
use SOAP::Transport::HTTP;
my $daemon = new SOAP::Transport::HTTP::Daemon(
LocalHost => '127.0.0.1',
LocalPort => 8000 );
$daemon->dispatch_to('Demo');;
$daemon->handle();
package Demo;
sub soapTest
{
my $self = shift;
my %hash = @_;
my $str;
foreach my $key(keys %hash){
print "$key = $hash{$key}\n";
}
}
-----------------
I'm using SOAP::Transport::HTTP::Daemon as I didn't have a handy server
around to use the CGI module as you did in your example. The main problem
you had was that you were trying to send a reference to a hash instead of
a hash...
Al.
------------------------------
Date: Tue, 22 Jul 2003 18:57:52 GMT
From: Xaonon <xaonon@hotpop.com>
Subject: Re: theory vs practice ceases power
Message-Id: <slrnbhr28c.gln.xaonon@xaonon.local>
Ned i bach <7fe97cc4.0307220357.6bc896da@posting.google.com>, Xah Lee
<xah@xahlee.org> teithant i thiw hin:
> Larry Wall likes to mention how he had a linguistics background, and
> how he utilized the (good) human qualities of English to create
> Perl. To the Perl folks of beady eyes, they are sold a grand advance
> in computer science, but to discerning eyes, it's artful garbage.
Bull. Perl is easy to program in, highly flexible and useful for a large
range of applications. Do you believe in results?
--
Xaonon, EAC Chief of Mad Scientists and informal BAAWA, aa #1821, Kibo #: 1
Visit The Nexus Of All Coolness (i.e. my site) at http://xaonon.dyndns.org/
"Since I do things on a regular basis that defies the laws of physics, I can
speak with some authority on the matter." -- vtailor@gte.net, in alt.atheism
------------------------------
Date: Tue, 22 Jul 2003 14:44:23 -0700
From: "David Oswald" <spamblock@junkmail.com>
Subject: Re: Using 'my' within nested loops
Message-Id: <vhrc3e1kh2oc8f@corp.supernews.com>
"Brian McCauley" <nobull@mail.com> wrote in message
news:u9adb6x0y5.fsf@wcl-l.bham.ac.uk...
> "David Oswald" <spamblock@junkmail.com> writes:
>
>
> Your Example 1 is, in fact, interpreted more like:
>
> my $this;
> my $that;
> foreach my $this (@somearray) {
> foreach my $that (@some_other_array) {
> ........
> }
> }
>
> IMNSHO Perl should emit a warning when it does this but it doesn't.
>
> > It seems to me that while the second example does a better job of
limiting
> > the scope of variables just to the block in which they're applicable,
the
> > second example does cause the construction of a variable each time the
outer
> > foreach iterates.
>
> Yes, that's what most people would intuatively think. That's why I think
we need
> a warning.
>
Thanks, that explains a lot. So would it be accurate to say that the
majority of the syntaxes that default to $_, are actually (behind the
scenes) calling something to the effect of my $_, and limiting its scope, or
is this nuance only applicable to foreach loops?
------------------------------
Date: Tue, 22 Jul 2003 20:25:40 +0200
From: Cliff Stanford <cms@may.be>
Subject: Wide character
Message-Id: <ZPSEvlCkGYH$Ew$K@mail.co.uk>
thread failed to start: Wide character in subroutine entry...
What on earth does this error mean? I can't find any reference.
Cliff.
------------------------------
Date: 22 Jul 2003 20:15:46 +0100
From: thomas@widmann.uklinux.net (Thomas M. Widmann)
Subject: Re: Wide character
Message-Id: <m3d6g2tlst.fsf@widmann.uklinux.net>
Cliff Stanford <cms@may.be> writes:
> thread failed to start: Wide character in subroutine entry...
>
> What on earth does this error mean? I can't find any reference.
I don't know that specific error message, but wide characters are
5.8-ese for Unicode characters > 0xff. For instance, if you try to
print such a character, you get the error message "Wide character in
print" (unless you specified it's OK to output UTF-8). See
perluniintro.
/Thomas
--
Thomas Widmann Bye-bye to BibTeX: join the Bibulus project now!
thomas@widmann.uklinux.net <http://www.nongnu.org/bibulus/>
Glasgow, Scotland, EU <http://savannah.nongnu.org/projects/bibulus/>
------------------------------
Date: Sat, 19 Jul 2003 01:59:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re:
Message-Id: <3F18A600.3040306@rochester.rr.com>
Ron wrote:
> Tried this code get a server 500 error.
>
> Anyone know what's wrong with it?
>
> if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {
(---^
> dienice("Please use the back button on your browser to fill out the Day
> & Route fields.");
> }
...
> Ron
...
--
Bob Walton
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 5259
***************************************