7

我需要创建一个如下所示的 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请求,$soap->__getLastRequest()因为它在发出请求之前返回了致命错误。同样,我不能在上使用var_dump()$resp因为它在执行该行之前就死了。我怎么知道实际发送的是什么?!如果我知道这一点,那么我可以更轻松地调试它。

谢谢, ns

4

1 回答 1

11

尝试类似的东西:

$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);       
于 2012-08-08T14:28:27.953 回答