SOAP-ERROR: Encoding: Object has no property

2019-06-17 11:11发布

I need to create a SOAP request which looks like this:

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

The operation expects this:

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

I have tried the following but keep hitting PHP Fatal error: SOAP-ERROR: Encoding: object has no 'start' property

I know that the token object can be created like this, as I have used it for another operation:

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

However, doing something similar for the 'start' parameter is failing with the fatal error message. Here's part of the code:

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

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

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

I am unable to print the full soap request using $soap->__getLastRequest() because it is returning the fatal error before issuing the request. Similarly, I cannot use var_dump() on the $resp because it dies before executing that line. How can I tell what is actually being sent?! If I know that, then I can debug this more easily.

Thanks, ns

1条回答
不美不萌又怎样
2楼-- · 2019-06-17 11:42

Try with something like that :

$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);       
查看更多
登录 后发表回答