Question

I am trying to generate a soap header like the one below

<SOAP-ENV:Header>
<RequesterCredentials xmlns="urn:ebay:api:PayPalAPI" xsi:type="ebl:CustomSecurityHeaderType">
<Credentials xmlns="urn:ebay:apis:eBLBaseComponents" xsi:type="ebl:UserIdPasswordType">
<Username>api_username</Username>
<Password>api_password</Password>
<Signature>api_signature</Signature>
<Subject>authorizing_account_emailaddress</Subject>
</Credentials>
</RequesterCredentials>
</SOAP-ENV:Header>

Reference:https://developer.paypal.com/webapps/developer/docs/classic/api/PayPalSOAPAPIArchitecture/

I am trying to do something below to generate this structure,

$credentialsHeader = new SoapHeader("urn:ebay:apis:eBLBaseComponents", "Credentials",
                     array(
                            "Username : username.user.name",
                            "Password : password",
                            "Signature : signature",
                            "Subject : my_email_id"
                                             ));
$requesterCredential = new SoapHeader("urn:ebay:api:PayPalAPI", "RequesterCredentials", $credentialsHeader);

$client->__setSoapHeaders(array($requesterCredential));

But I get an error :

{main}Authentication failed. API credentials are incorrect.

I am assuming I am doing something wrong in the way I am forming the headers? Some insights or help on this would be great.

Was it helpful?

Solution

It should be like this :

 $credentialsHeader = new SoapHeader("urn:ebay:apis:eBLBaseComponents", "Credentials",
                 array(
                        "Username"  => "username.user.name",
                        "Password"  => "password",
                        "Signature" => "signature",
                        "Subject" => "my_email_id"
                                         ));
$requesterCredential = new SoapHeader("urn:ebay:api:PayPalAPI", "RequesterCredentials", $credentialsHeader);
$client->__setSoapHeaders(array($requesterCredential));
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top