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!!

#!/usr/bin/perl -w

use strict;
use LWP::UserAgent;
use HTTP::Request::Common;
use SOAP::Lite;

use CGI::Carp qw/fatalsToBrowser/;


use warnings;
use CGI::Simple;
print "Content-Type: text/xml; charset=utf-8";


#foreach my $key (sort(keys(%ENV))) {
 #   print "$key = $ENV{$key}<br>\n";
#}

my $fieldsearch =param('fieldsearch');
my $fieldvalue = param('fieldvalue');

my $message = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://babel.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>0</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>";

              my $FS = "</xsd:fieldSearch>
               <xsd:fieldValue>";

               my $FV = "</xsd:fieldValue></xsd:params>
            <xsd:password>mc709cpq264i</xsd:password>
            <xsd:requestId>TestSearch</xsd:requestId>
            <xsd:resultView>2</xsd:resultView>
            <!--1 or more repetitions:-->
            <xsd:sortField>
               <xsd:sortField>1</xsd:sortField>
               <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 $sendit= $message.$fieldsearch.$FS.$fieldvalue.$FV;

my $userAgent = LWP::UserAgent->new();
my $request = HTTP::Request->new(POST => 'http://wsqa.nielsenbookdataonline.com/webservices/services/BDOLWebService?wsdl');
$request->header(SOAPAction => '"http://babel.webservices.book.nielsen.com/xsd"');
$request->content($sendit);
$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;
}

try added this above your commented out foreach loop.

my $cgi = new CGI::Simple;

then replace

my $fieldsearch =param('fieldsearch');
my $fieldvalue = param('fieldvalue');

with

my $fieldsearch =$cgi->param('fieldsearch');
my $fieldvalue = $cgi->param('fieldvalue');

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.