2014-01-17 105 views
0

我想產生一個SOAP頭類似下面SOAP請求與PHP SoapClient的(嵌套頭)

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

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

我嘗試做以下事情產生這種結構,

$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)); 

但我得到一個錯誤:

{main}Authentication failed. API credentials are incorrect. 

我假設我正在做錯的方式,我正在形成標題?對此的一些見解或幫助將會很大。

回答

0

它應該是這樣的:

$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));