I wanted to build an awesome place for people to discuss module specific issues, but I don't have any more time for this, and there are much better places to discuss Perl-related issues. I'd recommend asking your question on Stack Overflow or on Perl Monks.
If you are looking for a Perl tutorial or Perl-related news, I hope these links will serve you well.
Posted on 2009-05-08 13:20:56-07 by roscoe
how do you send variables to the client query?
script below sends to a server, but does not pass variables $thestring or $thevar to the script. It only works if I hard code the data strings into the xml
#!/usr/bin/perl -w use strict; use LWP::UserAgent; use HTTP::Request::Common; use SOAP::Lite; use CGI::Carp qw/fatalsToBrowser/; ## - christ this works! attempt to add data to string below ## sort field 0 isbn 1 title field value is the search string which is alphnumeric ##use strict; use warnings; my $thestring="cats"; my $thevar ="1"; $getsearch->value($thestring); # set new value $getmyvar->value($thevar); my $searchstring = $getsearch->value; # store it in variable my $sortfield = $getmyvar->value; # store it in variable # my $sortfield = SOAP::Data->type('string')->name('sortField')->value(1); print "Content-Type: text/xml; charset=utf-8"; ##my $searchstring = SOAP::Data->type('string')->name('fieldValue')->value(cats); my $message = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> <soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://ba +bel.webservices.book.nielsen.com/xsd\"> <soapenv:Header/> <soapenv:Body> <xsd:getSearchService> <xsd:param0> <xsd:clientId>BookmarcusBDWS01</xsd:clientId> <!--Optional:--> <xsd:currency>GBP</xsd:currency> <xsd:format>7</xsd:format> <xsd:from>0</xsd:from> <xsd:indexType>3</xsd:indexType> <!--Optional:--> <xsd:marketSegment>UK</xsd:marketSegment> <!--1 or more repetitions:--> <xsd:params> <!--Optional:--> <xsd:fieldLogic> <xsd:fieldLogic>0</xsd:fieldLogic> </xsd:fieldLogic> <xsd:fieldSearch>0</xsd:fieldSearch>"; $message = $message.$searchstring; $message = $message."</xsd:params> <xsd:password>mc709cpq264i</xsd:password> <xsd:requestId>TestSearch</xsd:requestId> <xsd:resultView>2</xsd:resultView> <!--1 or more repetitions:--> <xsd:sortField>"; $message = $message.$sortfield; $message = $message." <xsd:sortOrder>1</xsd:sortOrder> </xsd:sortField> <!--Optional:--> <xsd:territory>UK</xsd:territory> <xsd:to>4</xsd:to> </xsd:param0> </xsd:getSearchService> </soapenv:Body> </soapenv:Envelope>"; my $userAgent = LWP::UserAgent->new(); my $request = HTTP::Request->new(POST => 'http://wsqa.nielsenbookdataonline.com/webservices/service +s/BDOLWebService?wsdl'); $request->header(SOAPAction => '"http://babel.webservices.book.nielsen.com/xsd"'); $request->content($message); $request->content_type("text/xml; charset=utf-8"); my $response = $userAgent->request($request); if($response->code == 200) { print $response->as_string; } else { print $response->error_as_HTML; }
Direct Responses: Write a response