SOAP-ERROR: Encoding: Object has no property

非 Y 不嫁゛ 提交于 2019-12-08 17:33:58

问题


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:


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


来源:https://stackoverflow.com/questions/11866425/soap-error-encoding-object-has-no-property

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!