reading a variable in to my script

Reply

Join Date: Mar 2009
Posts: 4
Reputation: affee is an unknown quantity at this point 
Solved Threads: 0
affee affee is offline Offline
Newbie Poster

reading a variable in to my script

 
0
  #1
Jun 8th, 2009
I need to access 2 variables sent to this script;
fieldsearch and fieldvalue, both are sent from a php script (using passthru) but the sytax is incorrect as I get a 500 error :
[Mon Jun 8 12:17:51 2009] perlSOAP.cgi: Global symbol "$fieldsearch" requires explicit package name at perlSOAP.cgi line 64.
[Mon Jun 8 12:17:51 2009] perlSOAP.cgi: Global symbol "$fieldvalue" requires explicit package name at perlSOAP.cgi line 64.
help!!

  1. #!/usr/bin/perl -w
  2.  
  3. use strict;
  4. use LWP::UserAgent;
  5. use HTTP::Request::Common;
  6. use SOAP::Lite;
  7.  
  8. use CGI::Carp qw/fatalsToBrowser/;
  9.  
  10.  
  11. use warnings;
  12. use CGI::Simple;
  13. print "Content-Type: text/xml; charset=utf-8";
  14.  
  15.  
  16. #foreach my $key (sort(keys(%ENV))) {
  17. # print "$key = $ENV{$key}<br>\n";
  18. #}
  19.  
  20. my $fieldsearch =param('fieldsearch');
  21. my $fieldvalue = param('fieldvalue');
  22.  
  23. my $message = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
  24. <soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://babel.webservices.book.nielsen.com/xsd\">
  25. <soapenv:Header/>
  26. <soapenv:Body>
  27. <xsd:getSearchService>
  28. <xsd:param0>
  29. <xsd:clientId>BookmarcusBDWS01</xsd:clientId>
  30. <!--Optional:-->
  31. <xsd:currency>GBP</xsd:currency>
  32. <xsd:format>7</xsd:format>
  33. <xsd:from>0</xsd:from>
  34. <xsd:indexType>0</xsd:indexType>
  35. <!--Optional:-->
  36. <xsd:marketSegment>UK</xsd:marketSegment>
  37. <!--1 or more repetitions:-->
  38. <xsd:params>
  39. <!--Optional:-->
  40. <xsd:fieldLogic>
  41. <xsd:fieldLogic>0</xsd:fieldLogic>
  42. </xsd:fieldLogic>
  43. <xsd:fieldSearch>";
  44.  
  45. my $FS = "</xsd:fieldSearch>
  46. <xsd:fieldValue>";
  47.  
  48. my $FV = "</xsd:fieldValue></xsd:params>
  49. <xsd:password>mc709cpq264i</xsd:password>
  50. <xsd:requestId>TestSearch</xsd:requestId>
  51. <xsd:resultView>2</xsd:resultView>
  52. <!--1 or more repetitions:-->
  53. <xsd:sortField>
  54. <xsd:sortField>1</xsd:sortField>
  55. <xsd:sortOrder>1</xsd:sortOrder>
  56. </xsd:sortField>
  57. <!--Optional:-->
  58. <xsd:territory>UK</xsd:territory>
  59. <xsd:to>4</xsd:to>
  60. </xsd:param0>
  61. </xsd:getSearchService>
  62. </soapenv:Body>
  63. </soapenv:Envelope>";
  64. my $sendit= $message.$fieldsearch.$FS.$fieldvalue.$FV;
  65.  
  66. my $userAgent = LWP::UserAgent->new();
  67. my $request = HTTP::Request->new(POST => 'http://wsqa.nielsenbookdataonline.com/webservices/services/BDOLWebService?wsdl');
  68. $request->header(SOAPAction => '"http://babel.webservices.book.nielsen.com/xsd"');
  69. $request->content($sendit);
  70. $request->content_type("text/xml; charset=utf-8");
  71. my $response = $userAgent->request($request);
  72.  
  73.  
  74.  
  75.  
  76.  
  77. if($response->code == 200) {
  78. print $response->as_string;
  79.  
  80. }
  81. else {
  82. print $response->error_as_HTML;
  83. }
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 15
Reputation: wickedxter is an unknown quantity at this point 
Solved Threads: 0
wickedxter wickedxter is offline Offline
Newbie Poster

Re: reading a variable in to my script

 
0
  #2
Jul 13th, 2009
try added this above your commented out foreach loop.

my $cgi = new CGI:imple;
then replace
my $fieldsearch =param('fieldsearch');
my $fieldvalue = param('fieldvalue');
with

my $fieldsearch =$cgi->param('fieldsearch');
my $fieldvalue = $cgi->param('fieldvalue');
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC