Note that there are some explanatory texts on larger screens.

plurals
  1. POsimple php SoapClient example for paypal needed
    text
    copied!<p>Could I get a simple example of using PHP's SoapClient class to make an empty call to Paypal with nothing but the version number? I have the correct WSDL url and server url, so that's not what I need help with. This is what I have:</p> <pre><code>public function SOAPcall($function, $args=array()) { $args['Version'] = '63.0'; $args = new SoapVar($args, SOAP_ENC_ARRAY, $function.'_Request'); $args = array(new SoapVar($args, SOAP_ENC_ARRAY, $function.'_Req', 'urn:ebay:api:PayPalAPI')); $results = $this-&gt;soapClient-&gt;__soapCall($function, $args, array('location' =&gt; $this-&gt;activeKeys['certificate']), $this-&gt;soapOptions); } </code></pre> <p>I hope it's okay I am not showing everything. The body of the request comes out completely wrong, as you can see below:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns1="urn:ebay:api:PayPalAPI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns2="urn:ebay:apis:eBLBaseComponents"&gt; &lt;SOAP-ENV:Header&gt; &lt;ns1:RequesterCredentials&gt; &lt;ns2:Credentials&gt; &lt;ns2:Username&gt;xxx&lt;/ns2:Username&gt; &lt;ns2:Password&gt;xxx&lt;/ns2:Password&gt; &lt;ns2:Signature&gt;xxx&lt;/ns2:Signature&gt; &lt;/ns2:Credentials&gt; &lt;/ns1:RequesterCredentials&gt; &lt;/SOAP-ENV:Header&gt; &lt;SOAP-ENV:Body&gt; &lt;ns1:GetBalanceReq xsi:type="ns1:GetBalance_Req"&gt; &lt;xsd:string&gt;63.0&lt;/xsd:string&gt; &lt;/ns1:GetBalanceReq&gt; &lt;/SOAP-ENV:Body&gt; &lt;/SOAP-ENV:Envelope&gt; </code></pre> <p>It should look like this:</p> <pre><code>&lt;?xml version=”1.0” encoding=”UTF-8”?&gt; &lt;SOAP-ENV:Envelope xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xmlns:SOAP-ENC=”http://schemas.xmlsoap.org/soap/encoding/” xmlns:SOAP-ENV=”http://schemas.xmlsoap.org/soap/envelope/” xmlns:xsd=”http://www.w3.org/2001/XMLSchema” SOAP-ENV:encodingStyle=”http://schemas.xmlsoap.org/soap/encoding/” &gt;&lt;SOAP-ENV:Header&gt; &lt;RequesterCredentials xmlns=”urn:ebay:api:PayPalAPI”&gt; &lt;Credentials xmlns=”urn:ebay:apis:eBLBaseComponents”&gt; &lt;Username&gt;api_username&lt;/Username&gt; &lt;Password&gt;api_password&lt;/Password&gt; &lt;Signature/&gt; &lt;Subject/&gt; &lt;/Credentials&gt; &lt;/RequesterCredentials&gt; &lt;/SOAP-ENV:Header&gt; &lt;SOAP-ENV:Body&gt; &lt;specific_api_name_Req xmlns=”urn:ebay:api:PayPalAPI”&gt; &lt;specific_api_name_Request&gt; &lt;Version xmlns=urn:ebay:apis:eBLBaseComponents”&gt;service_version &lt;/Version&gt; &lt;required_or_optional_fields xsi:type=”some_type_here”&gt; data &lt;/required_or_optional_fields&gt; &lt;/specific_api_name_Request&gt; &lt;/specific_api_name_Req&gt; &lt;/SOAP-ENV:Body&gt; &lt;/SOAP-ENV:Envelope&gt; </code></pre> <p>Of course, Paypal throws a "Version is not supported" error.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload