2010-09-20 4 views
1

J'essaie d'utiliser la fonctionnalité de PushSubscription d'Exchange 2010. Jusqu'à présent, j'ai le code pour pousser l'installation sur Exchange 2010:Exchange 2010 PushSubscription WCF SOAP

ExchangeService esService = new ExchangeService(); 
esService.Credentials = new WebCredentials("user", "pass", "domain"); 
esService.Url = new Uri("https://exchange-box-2010/ews/exchange.asmx"); 

PushSubscription ps = esService.SubscribeToPushNotificationsOnAllFolders(new Uri("http://192.168.1.102:8080/FinWorkFlow"), 1, null, EventType.NewMail, EventType.Copied); 

J'ai aussi un WCF service qui exécute à http://192.168.1.102:80/FinWorkFlow avec un utilitaire de suivi tcp redirection de 8080 à 80. Les traces indiquent qu'Exchange envoie une demande à http://192.168.1.102:8080/FinWorkFlow et qu'une bonne réponse est envoyée à partir de mon service WCF. Cependant, le paramètre SendNotificationResponseType de la méthode sendNotification est toujours nulle:

SendNotificationResultType INotificationServiceBinding.SendNotification(SendNotificationResponseType request) 
     { 
      if(request != null && request.ResponseMessages != null) 
      { 
       foreach(ResponseMessageType messsage in request.ResponseMessages.Items) 
       { 
        if(messsage.ResponseCode != ResponseCodeType.NoError) 
        { 
         return CreateNotificationResult(SubscriptionStatusType.Unsubscribe); 
        } 

        SendNotificationResponseMessageType mtNotificationMessage = (SendNotificationResponseMessageType)messsage; 
        NotificationType ntNotification = mtNotificationMessage.Notification; 
        string strSubscriptionId = ntNotification.SubscriptionId; 

        for(int i = 0; i < ntNotification.Items.Length; i++) 
        { 
         if(ntNotification.ItemsElementName[i].ToString() == "NewMailEvent") 
         { 
          BaseObjectChangedEventType bocet = (BaseObjectChangedEventType)ntNotification.Items[i]; 
         } 
        } 
       } 
      } 

      return CreateNotificationResult(SubscriptionStatusType.OK); 
     } 

L'interface est définie comme:

[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")] 
[System.Web.Services.WebServiceBindingAttribute(Name = "NotificationServiceBinding", Namespace = "http://schemas.microsoft.com/exchange/services/2006/messages")] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(ServiceConfiguration))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(DirectoryEntryType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(TargetFolderIdType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(RecurrenceRangeBaseType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(RecurrencePatternBaseType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(AttachmentType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(BasePermissionType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(BaseItemIdType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(BaseEmailAddressType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(BaseFolderIdType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(BaseFolderType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(BaseResponseMessageType))] 
[ServiceContract(Namespace = "http://schemas.microsoft.com/exchange/services/2006/messages", ConfigurationName = "Microsoft.Exchange.Notifications.INotificationServicePortType")] 
public interface INotificationServiceBinding 
{ 

    /// <remarks/> 
    [OperationContract(Action = "*", ReplyAction = "*")] 
    [System.Web.Services.WebMethodAttribute()] 
    [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://schemas.microsoft.com/exchange/services/2006/messages/SendNotification", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Bare)] 
    [return: System.Xml.Serialization.XmlElementAttribute(Namespace = "http://schemas.microsoft.com/exchange/services/2006/messages")] 
    SendNotificationResultType SendNotification([System.Xml.Serialization.XmlElementAttribute("SendNotification", Namespace = "http://schemas.microsoft.com/exchange/services/2006/messages")] SendNotificationResponseType SendNotification1); 
} 

Une demande typique de change est:

POST /FinWorkFlow HTTP/1.1 
Content-Type: text/xml; charset=utf-8 
Accept: text/xml 
SOAPAction: http://schemas.microsoft.com/exchange/services/2006/messages/SendNotification 
Host: 192.168.1.102:8080 
Content-Length: 1486 
Connection: Close 

<?xml version="1.0" encoding="utf-8"?><soap11:Envelope xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/"><soap11:Header><RequestServerVersion xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" Version="Exchange2010" /></soap11:Header><soap11:Body><m:SendNotification xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"><m:ResponseMessages><m:SendNotificationResponseMessage ResponseClass="Success"><m:ResponseCode>NoError</m:ResponseCode><m:Notification><t:SubscriptionId>EgBiZnQtbWVybGluLnJibS5sYW4QAAAAz4lScRmxbEaLeCfsAFRDmEswGeTtJs0I</t:SubscriptionId><t:PreviousWatermark>AQAAAOUSjqlc3mdHh1LhIiuqSBc1UCgAAAAAAAA=</t:PreviousWatermark><t:MoreEvents>false</t:MoreEvents><t:NewMailEvent><t:Watermark>AQAAAOUSjqlc3mdHh1LhIiuqSBc8UCgAAAAAAAE=</t:Watermark><t:TimeStamp>2010-09-20T15:16:28Z</t:TimeStamp><t:ItemId Id="AAMkAGVmOWI3OGE5LWJmMjEtNDU4Mi1hY2JlLTdhYzZmMGQ2N2Q4ZABGAAAAAACd5Nq062e3ToqPr4+g8e/UBwDjUS8vlMohRaUyr3p641BAACy83CEfAABwOzEV48hOQJYkk18qYDCqAAAAnG3SAAA=" ChangeKey="CQAAAA==" /><t:ParentFolderId Id="AAMkAGVmOWI3OGE5LWJmMjEtNDU4Mi1hY2JlLTdhYzZmMGQ2N2Q4ZAAuAAAAAACd5Nq062e3ToqPr4+g8e/UAQDjUS8vlMohRaUyr3p641BAACy83CEfAAA=" ChangeKey="AQAAAA==" /></t:NewMailEvent></m:Notification></m:SendNotificationResponseMessage></m:ResponseMessages></m:SendNotification></soap11:Body></soap11:Envelope> 

Quelqu'un peut-il expliquer pourquoi le corps de la requête SOAP n'est pas récupéré et mis dans la variable SendNotificationResponseType?

+0

Ce mécanisme prend-il en charge les notifications lorsqu'un nouveau courrier arrive dans la boîte aux lettres? puis-je m'inscrire à un nouvel événement mails - une fois et recevoir les mails dès qu'ils arrivent à l'appareil, sans interroger et envoyer une requête au serveur toutes les quelques minutes ..? Je veux être en mesure de gérer les nouveaux mails instantanément possible. –

Répondre

0

Enfin compris!

Il s'avère que j'ai utilisé l'outil wsdl pour construire l'interface - aurait dû utiliser svcutil. Cela a construit une interface avec les attributs de méthode corrects.

Questions connexes