Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re: Problems with SOAP::Lite client

by Anonymous Monk
on Dec 11, 2008 at 15:07 UTC ( #729706=note: print w/replies, xml ) Need Help??

in reply to Problems with SOAP::Lite client

Here's one way
#!/usr/bin/perl -- use strict; use warnings; use SOAP::Lite; use SOAP::Lite 0.65 +trace => 'debug'; my $soap = SOAP::Lite->proxy( 'http://localhost/blah/DummyService' ); my $serializer = $soap->serializer(); print $serializer->envelope( method => 'updatePLZInformationen', SOAP::Data->type("xsd:string")->name( "clientid" => "test" ), SOAP::Data->type("xsd:string")->name( "securitytoken" => "test" ), SOAP::Data->type("tns2:PLZInfo")->name("plzinfos")->value( \SOAP::Data->value( SOAP::Data->name("kurzname")->type("xsd:string")->value("gargel"), SOAP::Data->name("plz")->type("xsd:string")->value("12345"), SOAP::Data->name("stadt")->type("xsd:string")->value("Musterstadt" +), SOAP::Data->name("status")->type("xsd:string")->value("0815"), SOAP::Data->name("typ")->type("xsd:string")->value("2"), SOAP::Data->name("zusatz")->type("xsd:string")->value("hinten rech +ts") ) ) ); __END__ perl | xml_pp <?xml version="1.0" encoding="UTF-8"?> <soap:Envelope soap:encodingStyle=" +oding/" xmlns:soap="" xmlns: +soapenc="" xmlns:xsd="http:/ +/" xmlns:xsi=" +ma-instance"> <soap:Body> <updatePLZInformationen> <clientid xsi:type="xsd:string">test</clientid> <securitytoken xsi:type="xsd:string">test</securitytoken> <plzinfos xsi:type="tns2:PLZInfo"> <kurzname xsi:type="xsd:string">gargel</kurzname> <plz xsi:type="xsd:string">12345</plz> <stadt xsi:type="xsd:string">Musterstadt</stadt> <status xsi:type="xsd:string">0815</status> <typ xsi:type="xsd:string">2</typ> <zusatz xsi:type="xsd:string">hinten rechts</zusatz> </plzinfos> </updatePLZInformationen> </soap:Body> </soap:Envelope>

Replies are listed 'Best First'.
Re^2: Problems with SOAP::Lite client
by thion (Initiate) on Dec 12, 2008 at 07:54 UTC

    thanks for the example.

    I tried to build it into my "real" code, but I'm messing up something. I'm reading data from a database here and generate an array of hashes:
    while($sth->fetch()) { my %hash; # Hash zusammenbasteln $hash{"kurzname"} = $kurzname; $hash{"plz"} = $plz; $hash{"stadt"} = $stadt; $hash{"status"} = $status; $hash{"typ"} = $typ; $hash{"zusatz"} = $zusatz; push(@ary,%hash); } $sth->finish(); $dss->updatePLZInformationen(@ary);
    And here is the function that's called and is doing the actual SOAP stuff:
    sub updatePLZInformationen() { my @data = shift; my $plz = SOAP::Lite -> service('file:/home/orca/oracle/DataSyncTool/config/SKADataServ +ice.wsdl'); my $serializer = $plz->serializer(); print($serializer->envelope( method => 'updatePLZInformationen', SOAP::Data->type("xsd:string")->name( "c +lientid" => "test" ), SOAP::Data->type("xsd:string")->name( "s +ecuritytoken" => "test" ), SOAP::Data->type("tns2:PLZInfo")->name(" +plzinfos")->value( \SOAP::Data->value(&format_plz_infos(@ +data))))); $plz->updatePLZInformationen(); } # -------------------------------------------------------------------- +---------------------------- # sub format_plz_infos() { my @plz = shift(); my @plz_info; foreach(@plz) { my $hash = $_; push(@plz_info,SOAP::Data->name("kurzname")->value($hash->{"ku +rzname"})->type("xsd:string")); push(@plz_info,SOAP::Data->name("plz")->value($hash->{"plz"})- +>type("xsd:string")); push(@plz_info,SOAP::Data->name("stadt")->value($hash->{"stadt +"})->type("xsd:string")); push(@plz_info,SOAP::Data->name("status")->value($hash->{"stat +us"})->type("xsd:string")); push(@plz_info,SOAP::Data->name("typ")->value($hash->{"typ"})- +>type("xsd:string")); push(@plz_info,SOAP::Data->name("zusatz")->value($hash->{"zusa +tz"})->type("xsd:string")); } return(@plz_info); } # -------------------------------------------------------------------- +---------------------------- #
    And this is my SOAP-message:
    ?xml version="1.0" encoding="UTF-8"?> <soap:Envelope xmlns:xsi="" xmlns:soapenc="" xmlns:xsd="" soap:encodingStyle="" xmlns:soap=""> <soap:Body><updatePLZInformationen> <clientid xsi:type="xsd:string">test</clientid> <securitytoken xsi:type="xsd:string">test</securitytoken> <plzinfos xsi:type="tns2:PLZInfo"> <kurzname xsi:nil="true" xsi:type="xsd:string" /> <plz xsi:nil="true" xsi:type="xsd:string" /> <stadt xsi:nil="true" xsi:type="xsd:string" /> <status xsi:nil="true" xsi:type="xsd:string" /> <typ xsi:nil="true" xsi:type="xsd:string" /> <zusatz xsi:nil="true" xsi:type="xsd:string" /> </plzinfos> </updatePLZInformationen> </soap:Body> </soap:Envelope>
    The message looks good, but it has no values... I'm reading my code for about an hour now, but I don't seem to get the mistake. :-(

    Thanks in advance,

      That is confusing. Instead of this
      you probably meant
      push @ary, \%hash;
      but then you probably meant
      instead. I could probably guess what you're really after, but its better if you pseudocode/diagram what you wish to accomplish, before writing actual code.

        ok, I'll try to explain:
        I walk through a database table and build a hash for each record in my resultset. This hash is pushed into an array. When the data-collecting is finished I call a subroutine (updatePLZInformationen()) to make the soap-call and pass the array of hashes. Ths subroutine calls another subroutine to format the complex type "plzinfo". Then it calls the soap-server. That's about it.
        But somewhere in the subroutines my values get lost...
        I'm sure it's just some stupid mistake, but I don't get it...
        Thanks again,


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://729706]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (4)
As of 2018-06-24 07:36 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (126 votes). Check out past polls.