【问题标题】:php -ews - Push notificationsphp -ews - 推送通知
【发布时间】:2019-01-11 14:37:09
【问题描述】:

我正在订阅日历事件的 EWS 推送通知并记录通知。

我正在使用 PHP-EWS:jamesiarmes/php-ews 和 Symfony 4.1

要订阅我正在使用此代码:

    $ews = new Client($this->host, $this->username, $this->password, $this->version);
    $ews->setCurlOptions($this->curlOptions);

    $eventTypes = new NonEmptyArrayOfNotificationEventTypesType();
    $eventTypes->EventType[] = NotificationEventTypeType::CREATED_EVENT;
    $eventTypes->EventType[] = NotificationEventTypeType::MODIFIED_EVENT;
    $eventTypes->EventType[] = NotificationEventTypeType::DELETED_EVENT;

    $eventTypes->EventType[] = NotificationEventTypeType::COPIED_EVENT;
    $eventTypes->EventType[] = NotificationEventTypeType::MOVED_EVENT;


    $folderIDs = new NonEmptyArrayOfBaseFolderIdsType();
    $folderIDs->DistinguishedFolderId = new DistinguishedFolderIdType();
    $folderIDs->DistinguishedFolderId->Id = DistinguishedFolderIdNameType::CALENDAR;


    $pushSubscription = new PushSubscriptionRequestType();
    $pushSubscription->FolderIds = $folderIDs;
    $pushSubscription->EventTypes = $eventTypes;


    $pushSubscription->StatusFrequency = 1;
    $pushSubscription->URL = $url;

    $subscribe_request = new SubscribeType();
    $subscribe_request->PushSubscriptionRequest = $pushSubscription;

    $response = $ews->Subscribe($subscribe_request);

    return $response;

我的 WSDL 看起来像这样,我正在使用 zend soap 的自动发现功能来自动生成这个:

<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
         xmlns:tns="http://192.168.11.7/app_dev.php/api/soap/server"
         xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
         xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/"
         xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" name="ExchangeSoapService"
         targetNamespace="http://192.168.11.7/app_dev.php/api/soap/server">
<types>
    <xsd:schema targetNamespace="http://192.168.11.7/app_dev.php/api/soap/server"/>
</types>
<portType name="ExchangeSoapServicePort">
    <operation name="SendNotification">
        <documentation>Check soap service, display name when called</documentation>
        <input message="tns:SendNotificationIn"/>
        <output message="tns:SendNotificationOut"/>
    </operation>
</portType>
<binding name="ExchangeSoapServiceBinding" type="tns:ExchangeSoapServicePort">
    <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
    <operation name="SendNotification">
        <soap:operation soapAction="http://192.168.11.7/app_dev.php/api/soap/server#SendNotification"/>
        <input>
            <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
                       namespace="http://192.168.11.7/app_dev.php/api/soap/server"/>
        </input>
        <output>
            <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
                       namespace="http://192.168.11.7/app_dev.php/api/soap/server"/>
        </output>
    </operation>
</binding>
<service name="ExchangeSoapServiceService">
    <port name="ExchangeSoapServicePort" binding="tns:ExchangeSoapServiceBinding">
        <soap:address location="http://192.168.11.7/app_dev.php/api/soap/server"/>
    </port>
</service>
<message name="SendNotificationIn">
    <part name="arg" type="xsd:anyType"/>
</message>
<message name="SendNotificationOut">
    <part name="return" type="xsd:anyType"/>
</message>

经过一番摸索,我获得了一个成功代码,其中包括一个 SubscriptionId 和 Watermark,但它无法获得通知!

有人可以帮忙吗?我究竟做错了什么? 如何检查交易所是否正在发送通知? 我的交易所是否有可能禁用了通知?

【问题讨论】:

    标签: php exchange-server exchangewebservices php-ews


    【解决方案1】:

    成功订阅后没有收到通知通常是防火墙问题或路由/DNS 问题。我认为您没有共享您在$url 中设置的内容,但是如果 URL 中有端口,则必须在防火墙上打开它,如果其中有主机名,则该名称必须是 PINGable 来自 Exchange 服务器。

    【讨论】:

    • 我的网址是:$uri = "192.168.11.7/app_dev.php/api/soap/server"!我尝试在控制台表单交换服务器中 ping 它,然后在浏览器中运行这个 url,它在这两种情况下都有效。交换服务器使用什么端口进行通知?
    • 是的,它是 http.// 在 url 之前,但是 http 是否正确?
    • 是的,如果您通过 IP 地址访问,那么 HTTPS 将不起作用。如果您可以通过浏览器进行对话,那么您的应用服务器上的端口 80 已打开。但是,您可以尝试让您的应用在不同的端口上侦听,例如8080,然后打开那个端口。由于 IIS 几乎可以控制 80 和 443,因此您可能应该让您的应用程序侦听该端口以外的端口。
    • 我使用 IP 和 HTTP!我现在可以正常工作,尝试一些东西,它就开始工作了!但我有一个问题(在 stackoverflow 中打开),我从交易所收到关于新事件或更新事件的通知,但 ItemId 为空!
    猜你喜欢
    • 2019-01-06
    • 2015-09-14
    • 1970-01-01
    • 2013-10-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-19
    相关资源
    最近更新 更多