php SOAP-ERROR:编码:对象没有属性

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11866425/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 02:18:27  来源:igfitidea点击:

SOAP-ERROR: Encoding: Object has no property

phpweb-servicessoapsoap-client

提问by nonshatter

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

我需要创建一个如下所示的 SOAP 请求:

<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

我尝试了以下但继续打 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:

但是,对 'start' 参数执行类似操作失败并显示致命错误消息。这是代码的一部分:

$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 $respbecause 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.

我无法打印完整的soap请求,$soap->__getLastRequest()因为它在发出请求之前返回致命错误。同样,我不能使用var_dump()on ,$resp因为它在执行该行之前就死了。我怎么知道实际发送的是什么?!如果我知道这一点,那么我可以更轻松地调试它。

Thanks, ns

谢谢, ns

回答by Anas

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