尝试使用 SOAP 获取值时未定义的属性


Undefined property while attempting to get values using SOAP

我正在用Openmeetings的SOAP API进行冒险。 这是我第一次使用 SOAP 进行牛仔竞技表演,所以如果这里的解决方案看起来很明显,请不要担心。

无论如何,我正在尝试使用以下脚本检索会话 id。

<?php
    $wsdl = "http://localhost:5080/openmeetings/services/UserService?wsdl";
    $session = new SoapClient($wsdl, array("trace" =>1, "exceptions"=>0));
    $value = $session->getSession();
    $xml = $value->getSessionResponse;
    $ssid = $xml->session_id;
    print "<br/>'n SSID: $ssid";
?>

但是我收到以下错误:

注意:未定义的属性:stdClass::$getSessionResponse in/home/sam/www/soap.php 第 5 行
注意:尝试在第 6 行的/home/sam/www/soap.php 中获取非对象的属性

使用 soapUI,我可以看到发送了以下内容:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://services.axis.openmeetings.apache.org">
  <soapenv:Header/>
  <soapenv:Body>
      <ser:getSession/>
  </soapenv:Body>
</soapenv:Envelope>

当我在soapUI上执行它时,将返回以下内容(其中包含我想要的所有内容以及更多内容(:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
  <soapenv:Body>
      <ns:getSessionResponse xmlns:ns="http://services.axis.openmeetings.apache.org">
    <ns:return xsi:type="ax22:Sessiondata" xmlns:ax27="http://asterisk.sip.beans.persistence.openmeetings.apache.org/xsd" xmlns:ax213="http://basic.beans.data.openmeetings.apache.org/xsd" xmlns:ax24="http://domain.beans.persistence.openmeetings.apache.org/xsd" xmlns:ax21="http://user.beans.persistence.openmeetings.apache.org/xsd" xmlns:ax22="http://basic.beans.persistence.openmeetings.apache.org/xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <ax22:id>14</ax22:id>
        <ax22:language_id xsi:nil="true"/>
        <ax22:organization_id xsi:nil="true"/>
        <ax22:refresh_time>2013-09-26</ax22:refresh_time>
        <ax22:sessionXml xsi:nil="true"/>
        <ax22:session_id>90a4d3dc876460e119d068969def236c</ax22:session_id>
        <ax22:starttermin_time>2013-09-26</ax22:starttermin_time>
        <ax22:storePermanent xsi:nil="true"/>
        <ax22:user_id xsi:nil="true"/>
    </ns:return>
      </ns:getSessionResponse>
  </soapenv:Body>
</soapenv:Envelope

由于 soapUI 适用于它,因此我确定我使用的网址是正确的,并且 API 是可靠的。 任何人都可以在我的 php 中找到我哪里不对劲吗?

作为参考,可以在此处找到Openmeetings 的 SOAP API 文档。 以防有人发现有用或有趣。

提前非常感谢任何能够检测到错误的人......或者任何为此试一试的人。

这里有点尴尬。 当我在帖子中编辑语法时,我注意到我应该使用"return"而不是"getSessionResponse"。 我只是替换了

$xml = $value->getSessionResponse;

$xml = $value->return;

它就像一个魅力。

很抱歉浪费服务器空间:-P