PHP EWS 订阅响应错误编码对象没有 属性
PHP EWS Subscription Response error encoding object has no property
我正在使用 garethp/php-ews 库下载推送到我的脚本(通过推送通知)的新电子邮件。作为推送通知的一部分,我需要以 "OK" 状态进行响应;我下面的尝试是抛出一个 SOAP 错误:
PHP Fatal error: SOAP-ERROR: Encoding: object has no
'SubscriptionStatus' property in ...
<?php
ini_set("soap.wsdl_cache_enabled", 0);
require_once('vendor/autoload.php');
use garethp\ews\API;
use garethp\ews\API\ExchangeWebServicesAuth;
use garethp\ews\API\Type\ConnectingSIDType;
use garethp\ews\API\Type\ExchangeImpersonation;
use garethp\ews\API\Type\ItemIdType;
use garethp\ews\API\Type\NonEmptyArrayOfBaseItemIdsType;
use garethp\ews\API\Type\ItemResponseShapeType;
use garethp\ews\API\Message\SendNotificationResultType;
use garethp\ews\API\Message\SendNotificationResult;
use garethp\ews\API\Message\ArrayOfResponseMessagesType;
use garethp\ews\API\Message\SendNotificationResponseType;
use garethp\ews\API\Message\GetItemType;
use garethp\ews\API\Enumeration\DefaultShapeNamesType;
use garethp\ews\API\Enumeration\SubscriptionStatusType;
class EwsPushService
{
public function SendNotification($arg)
{
$responseCode = $arg->ResponseMessages->SendNotificationResponseMessage->ResponseCode;
if ($responseCode == "NoError") {
$notification = $arg->ResponseMessages->SendNotificationResponseMessage->Notification;
if (isset($notification->NewMailEvent)) {
// Download message
}
}
$notificationResponse = new SendNotificationResultType();
$notificationResponse->setSubscriptionStatus(SubscriptionStatusType::OK);
return $notificationResponse;
}
}
$service = new EwsPushService();
$server = new SoapServer('php-ews/wsdl/NotificationService.wsdl');
$server->setObject($service);
$server->handle();
我试图删除缓存的 WSDL 文件,并在我的脚本中将 soap.wsdl_cache_enabled
设置为 0,但没有成功。我使用的 WSDL 来自 nginn-exchange,并添加了少量内容:
<wsdl:service name="NotificationServices">
<wsdl:port name="NotificationServicePort" binding="tns:NotificationServiceBinding">
<soap:address location="" />
</wsdl:port>
</wsdl:service>
我不确定出了什么问题,也不确定查看 SOAP 问题的最佳方法,但我们将不胜感激任何建议。
[编辑]
我相信问题实际上出在我正在使用的库上;所以我提出了 an issue 并会在我确定时更新...
该库符合 PSR-2 代码风格,因此订阅状态存储在一个名为 $subscriptionStatus
的变量中,通常这会作为 [= 的结果传递给 ucfirst 12=] 在 Type
class 中调用,这在我的案例中没有发生。为了解决这个问题,我需要像这样调用 toXmlObject
:
$notificationResponse = new SendNotificationResultType();
$notificationResponse->setSubscriptionStatus(SubscriptionStatusType::OK);
return $notificationResponse->toXmlObject();
我正在使用 garethp/php-ews 库下载推送到我的脚本(通过推送通知)的新电子邮件。作为推送通知的一部分,我需要以 "OK" 状态进行响应;我下面的尝试是抛出一个 SOAP 错误:
PHP Fatal error: SOAP-ERROR: Encoding: object has no 'SubscriptionStatus' property in ...
<?php
ini_set("soap.wsdl_cache_enabled", 0);
require_once('vendor/autoload.php');
use garethp\ews\API;
use garethp\ews\API\ExchangeWebServicesAuth;
use garethp\ews\API\Type\ConnectingSIDType;
use garethp\ews\API\Type\ExchangeImpersonation;
use garethp\ews\API\Type\ItemIdType;
use garethp\ews\API\Type\NonEmptyArrayOfBaseItemIdsType;
use garethp\ews\API\Type\ItemResponseShapeType;
use garethp\ews\API\Message\SendNotificationResultType;
use garethp\ews\API\Message\SendNotificationResult;
use garethp\ews\API\Message\ArrayOfResponseMessagesType;
use garethp\ews\API\Message\SendNotificationResponseType;
use garethp\ews\API\Message\GetItemType;
use garethp\ews\API\Enumeration\DefaultShapeNamesType;
use garethp\ews\API\Enumeration\SubscriptionStatusType;
class EwsPushService
{
public function SendNotification($arg)
{
$responseCode = $arg->ResponseMessages->SendNotificationResponseMessage->ResponseCode;
if ($responseCode == "NoError") {
$notification = $arg->ResponseMessages->SendNotificationResponseMessage->Notification;
if (isset($notification->NewMailEvent)) {
// Download message
}
}
$notificationResponse = new SendNotificationResultType();
$notificationResponse->setSubscriptionStatus(SubscriptionStatusType::OK);
return $notificationResponse;
}
}
$service = new EwsPushService();
$server = new SoapServer('php-ews/wsdl/NotificationService.wsdl');
$server->setObject($service);
$server->handle();
我试图删除缓存的 WSDL 文件,并在我的脚本中将 soap.wsdl_cache_enabled
设置为 0,但没有成功。我使用的 WSDL 来自 nginn-exchange,并添加了少量内容:
<wsdl:service name="NotificationServices">
<wsdl:port name="NotificationServicePort" binding="tns:NotificationServiceBinding">
<soap:address location="" />
</wsdl:port>
</wsdl:service>
我不确定出了什么问题,也不确定查看 SOAP 问题的最佳方法,但我们将不胜感激任何建议。
[编辑] 我相信问题实际上出在我正在使用的库上;所以我提出了 an issue 并会在我确定时更新...
该库符合 PSR-2 代码风格,因此订阅状态存储在一个名为 $subscriptionStatus
的变量中,通常这会作为 [= 的结果传递给 ucfirst 12=] 在 Type
class 中调用,这在我的案例中没有发生。为了解决这个问题,我需要像这样调用 toXmlObject
:
$notificationResponse = new SendNotificationResultType();
$notificationResponse->setSubscriptionStatus(SubscriptionStatusType::OK);
return $notificationResponse->toXmlObject();