Home » Php » php – SOAP-ERROR: Encoding: Object has no property

php – SOAP-ERROR: Encoding: Object has no property

Posted by: admin July 12, 2020 Leave a comment


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


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.


How to&Answers:

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