Can't call method "valueof" without a package or object reference in this line:
Why would I get this error? PLease see XML responce and PERL code:my $expresspaymentresponse = $response->valueof('//SetExpressCheckoutR +esponse/Token');
[CODE]#!/usr/bin/perl ## Allow test from browser print "Content-type: text/html\n\n"; use SOAP::Lite +trace; use Data::Dumper; $ENV{HTTPS_CERT_FILE} = '/hsphere/local/home/cgi-bin/test/ppcal_data/c +ert_key_pem.txt'; $ENV{HTTPS_KEY_FILE} = '/hsphere/local/home/cgi-bin/test/ppcal_data/c +ert_key_pem.txt'; *SOAP::XMLSchema2001::Deserializer::as_token = \&SOAP::XMLSchema1999:: +Deserializer::as_string; # Set the version my $version = "1.0"; # Retrieve the username, password, and transaction ID from the command + line my $api_username = "999_api1.mail.com"; my $api_password = "pass"; my $ordertotal = "10.99"; my $returnurl = 'http://www.zzz.com'; my $cancelurl = 'http://www.zzz.com'; # The base namespace my $xmlns = 'urn:ebay:api:PayPalAPI'; # Create the SOAP call. # https://api.sandbox.paypal.com/wsdl/PayPalSvc.wsdl my $service = SOAP::Lite ->proxy('https://api.sandbox.paypal.com/2.0/') ->readable(1) ->outputxml(1) ->uri('urn:ebay:api:PayPalAPI') ->on_action(sub{ sprintf "%s%s", @_ }); my $request = SOAP::Data->name( "SetExpressCheckoutRequest" => \SOAP::Data->value( SOAP::Data->name( "Version" => $version )->attr( {xmlns=>"urn:ebay:apis:eBLBaseComponents"} )->type(""), SOAP::Data->name( "SetExpressCheckoutRequestDetails" => \SOAP::Data->value( SOAP::Data->name( "OrderTotal" => $ordertotal )->attr({"currencyID"=>"USD"})->type(""), SOAP::Data->name( "ReturnURL" => $returnurl )->type(""), SOAP::Data->name( "CancelURL" => $cancelurl )->type(""), ) )->attr( {xmlns=>"urn:ebay:apis:eBLBaseComponents"} ) ) ); # Create the Security Header my $header = SOAP::Header->name("RequesterCredentials" => \SOAP::Header->value( SOAP::Data->name("Credentials" => \SOAP::Data->value( SOAP::Data->name("Username" => $api_username)->type(""), SOAP::Data->name("Password" => $api_password)->type(""), SOAP::Data->name("Subject")->type("") ) )->attr({xmlns=>"urn:ebay:apis:eBLBaseComponents"}) ) )->attr({xmlns=>$xmlns})->mustUnderstand("1"); # Create the Method my $method = SOAP::Data ->name('SetExpressCheckoutReq') ->attr({xmlns=>$xmlns}); *SOAP::Deserializer::typecast = sub {shift; return shift}; # Execute the call my $response = $service->call($header, $method => $request); my $expresspaymentresponse = $response->valueof('//SetExpressCheckoutR +esponse/Token'); my $teststring = Data::Dumper->Dump([$expresspaymentresponse] , ['*exp +resspaymentresponse']); print "$teststring"; exit;
<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-EN +V="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http:// +schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/1999 +/XMLSchema-instance" xmlns:xsd="http://www.w3.org/1999/XMLSchema" xml +ns:xs="http://www.w3.org/2001/XMLSchema" xmlns:cc="urn:ebay:apis:Core +ComponentTypes" xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/07/util +ity" xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion" xmlns:ds="htt +p://www.w3.org/2000/09/xmldsig#" xmlns:wsse="http://schemas.xmlsoap.o +rg/ws/2002/12/secext" xmlns:ebl="urn:ebay:apis:eBLBaseComponents" xml +ns:ns="urn:ebay:api:PayPalAPI"><SOAP-ENV:Header><Security xmlns="http +://schemas.xmlsoap.org/ws/2002/12/secext" xsi:type="wsse:SecurityType +"></Security><RequesterCredentials xmlns="urn:ebay:api:PayPalAPI" xsi +:type="ebl:CustomSecurityHeaderType"><Credentials xmlns="urn:ebay:api +s:eBLBaseComponents" xsi:type="ebl:UserIdPasswordType"><Username xsi: +type="xs:string"></Username><Password xsi:type="xs:string"></Password +><Subject xsi:type="xs:string"></Subject></Credentials></RequesterCre +dentials></SOAP-ENV:Header><SOAP-ENV:Body id="_0"><SetExpressCheckout +Response xmlns="urn:ebay:api:PayPalAPI"><Timestamp xmlns="urn:ebay:ap +is:eBLBaseComponents">2005-09-10T04:32:10Z</Timestamp><Ack xmlns="urn +:ebay:apis:eBLBaseComponents">Success</Ack><CorrelationID xmlns="urn: +ebay:apis:eBLBaseComponents">NotSet</CorrelationID><Version xmlns="ur +n:ebay:apis:eBLBaseComponents">1.000000</Version><Build xmlns="urn:eb +ay:apis:eBLBaseComponents">1.0006</Build><Token xsi:type="ebl:Express +CheckoutTokenType">EC-1K6559638C886540F</Token></SetExpressCheckoutRe +sponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
In reply to Error reading XML with SOAP by morbid_ru
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |