2012-08-08 61 views
7

我需要創建一個SOAP請求,看起來像這樣:SOAP的錯誤:編碼:對象沒有財產

<soapenv:Body> 
<getItemsForProject> 
    <token> 
     <user>?</user> 
     <password>?</password> 
    </token> 
    <projectId></projectId> 
    <start>0</start> 
    <count>0</count> 
</getItemsForProject> 
</soapenv:Body> 

的操作需要這樣的:

[209] => struct getItemsForProject { 
wsAuth token; 
long projectId; 
int start; 
int count; 
} 

我曾嘗試以下,但繼續打PHP Fatal error: SOAP-ERROR: Encoding: object has no 'start' property

我知道可以像這樣創建令牌對象,因爲我已經將它用於另一個操作:

$auth->token = new \stdClass; 
$auth->token->user = $username; 
$auth->token->password = $password; 

但是,對'start'參數做類似的操作是因致命錯誤消息而失敗。下面是部分代碼:

$opts = new \StdClass; 
$opts->projectId = 123; 
$opts->start = 0; 
$opts->count = 0; 

$resp = $soap->getItemsForProject($auth, $opts);  

echo $soap->__getLastRequest() ."\n"; 

我無法打印使用$soap->__getLastRequest(),因爲它是在發出請求之前返回致命錯誤完整SOAP請求。同樣,我不能在$resp上使用var_dump(),因爲它在執行該行之前死亡。我怎麼知道實際發送的內容?如果我知道,那麼我可以更容易地調試。

感謝, NS

回答

10

有類似的東西嘗試:

$myClass->token = new \stdClass; 
$myClass->token->user = $username; 
$myClass->token->password = $password; 

$myClass->projectId = 123; 
$myClass->start = 0; 
$myClass->count = 0; 


$resp = $soap->getItemsForProject($myClass);  
相關問題