1

I am subscribing to EWS push notifications for calendar events and to log notifications.

I am using PHP-EWS: jamesiarmes/php-ews and Symfony 4.1

To subscribe I'm using this code:

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

My WSDL looks like this, I'm using zend soap's autodiscovery function to auto generate this:

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

After some figuring out I obtain a success code, that includes a SubscriptionId and Watermark, but it fails to get the notification!

Can someone help with this? What am I doing wrong? How can I check if exchange is sending notifications? Is it possible that my exchange has notifications disabled?

Roman Pokrovskij
  • 9,449
  • 21
  • 87
  • 142

1 Answers1

1

Typically notifications not coming in after a successful subscribe is either a firewall issue or a routing/DNS issue. I don't think you've shared what you have set in $url but if there's a port in the URL, it has to be opened on the firewall, and if there's a hostname in it, that name has to be PINGable from the Exchange server.

pjneary
  • 1,136
  • 6
  • 8
  • My url is : $uri = "http://192.168.11.7/app_dev.php/api/soap/server"! I try to ping it in console form exchange server, and i run this url in browser ,and it work in both case. What port is used by exchange server for the notification? – Christophe Soares Aug 07 '18 at 08:35
  • Yes it is http.// before url, is it correct to but http? – Christophe Soares Aug 08 '18 at 08:11
  • Yes, if you're going via IP address, then HTTPS won't work. if you can get this to talk via the browser, then port 80 is open on your app server. However, you might try having your app listen on a different port, e.g. 8080, and then open that port. Since IIS pretty much takes control of 80 and 443, you probably should have your app listening on a port other than that one. – pjneary Aug 19 '18 at 03:23
  • I using IP with HTTP! i have it working right now , try some stuff and it start working! but i have a issue(open here in stackoverflow) , i get notification from exchange abour new or updated events, but the ItemId is null! – Christophe Soares Sep 03 '18 at 08:58