我们正在使用流式事件从Office 365中的不同用户的EWS收到通知。
为此,我们建立了一个订阅管理器来管理与不同服务器的连接。打开订阅的调用如下所示:
<android.support.v4.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#EDEDED">
<TextView
android:id="@+id/guestsLabelGuestRegistration"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingTop="24dp"
android:text="Gosti"
android:textStyle="bold" />
<android.support.design.widget.TextInputLayout
android:id="@+id/textInputLayoutOfferedService"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/guestsLabelGuestRegistration"
android:layout_marginLeft="@dimen/padding10dp"
android:layout_marginRight="@dimen/padding10dp"
android:layout_marginTop="@dimen/padding10dp"
android:background="@color/caldroid_white">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="4dp"
android:text="Vrsta usluge"
android:textSize="12dp" />
<android.support.v7.widget.AppCompatSpinner
android:id="@+id/spinnerOfferedService"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="2dp"
android:theme="@style/customSpinnerTheme" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/textInputArrivalOrganizations"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/textInputLayoutOfferedService"
android:layout_marginLeft="@dimen/padding10dp"
android:layout_marginRight="@dimen/padding10dp"
android:layout_marginTop="@dimen/padding10dp"
android:background="@color/caldroid_white">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="4dp"
android:text="Organizacija dolaska"
android:textSize="12dp" />
<android.support.v7.widget.AppCompatSpinner
android:id="@+id/spinnerArrivalOrganization"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:clipToPadding="true"
android:theme="@style/customSpinnerTheme" />
</android.support.design.widget.TextInputLayout>
<LinearLayout
android:id="@+id/linearLayoutHoursGuestRegistrationWrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/textInputArrivalOrganizations"
android:layout_marginLeft="@dimen/padding10dp"
android:layout_marginRight="@dimen/padding10dp"
android:layout_marginTop="@dimen/padding10dp"
android:background="@color/caldroid_white">
<RelativeLayout
android:id="@+id/relativeLayoutArrivalHourGuestRegistrationFragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingBottom="@dimen/padding5dp"
android:paddingTop="@dimen/padding5dp">
<TextView
android:id="@+id/textViewArrivalHourGuestRegistrationFragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="10:00"
android:textSize="22dp" />
<TextView
android:id="@+id/textViewLabelArrivalHourGuestRegistrationFragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/textViewArrivalHourGuestRegistrationFragment"
android:layout_centerHorizontal="true"
android:text="Sat dolaska"
android:textColor="@color/gray_dark" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/relativeLayoutDepartureHourGuestRegistrationFragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingBottom="@dimen/padding5dp"
android:paddingTop="@dimen/padding5dp">
<TextView
android:id="@+id/textViewDepartureHourGuestRegistrationFragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="14:00"
android:textSize="22dp" />
<TextView
android:id="@+id/textViewLabelDepartureHourGuestRegistrationFragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/textViewDepartureHourGuestRegistrationFragment"
android:layout_centerHorizontal="true"
android:text="Sat odlaska"
android:textColor="@color/gray_dark" />
</RelativeLayout>
</LinearLayout>
<TextView
android:id="@+id/guestsRegisterOnEvisitorLabelGuestRegistration"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/linearLayoutHoursGuestRegistrationWrapper"
android:gravity="center"
android:paddingTop="24dp"
android:text="Prijavi goste na eVisitor"
android:textStyle="bold" />
<ListView
android:id="@+id/eVisitorGuestsList"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@id/guestsRegisterOnEvisitorLabelGuestRegistration"
android:layout_margin="10dp"
android:layout_marginBottom="10dp"
android:layout_marginTop="5dp"
android:background="@color/caldroid_white"
android:cacheColorHint="@android:color/transparent"
android:divider="#CCCCCC"
android:dividerHeight="1dp"
android:paddingLeft="2dp"></ListView>
<TextView
android:id="@+id/newGuestLabelGuestRegistration"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/eVisitorGuestsList"
android:gravity="center"
android:paddingTop="24dp"
android:text="Unos novog gosts"
android:textStyle="bold" />
<LinearLayout
android:id="@+id/scanDocumentLinearLayoutClickWrapper"
android:layout_width="match_parent"
android:layout_height="25dp"
android:layout_alignLeft="@+id/linearLayoutHoursGuestRegistrationWrapper"
android:layout_alignStart="@+id/linearLayoutHoursGuestRegistrationWrapper"
android:layout_below="@+id/newGuestLabelGuestRegistration"
android:layout_marginTop="@dimen/padding10dp">
<ImageView
android:id="@+id/imageViewScanCardGuestRegistration"
android:layout_width="25dp"
android:layout_height="25dp"
android:adjustViewBounds="true"
android:background="@drawable/ic_image_white_48dp"
android:backgroundTint="#d50000" />
<TextView
android:id="@+id/textViewScanCardGuestRegistration"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:allowUndo="false"
android:text="Skeniraj osobnu iskaznicu"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#d50000" />
</LinearLayout>
<LinearLayout
android:id="@+id/enterNewGuestLinearLayoutClickWrapper"
android:layout_width="match_parent"
android:layout_height="25dp"
android:layout_alignLeft="@+id/linearLayoutHoursGuestRegistrationWrapper"
android:layout_alignStart="@+id/linearLayoutHoursGuestRegistrationWrapper"
android:layout_below="@+id/scanDocumentLinearLayoutClickWrapper"
android:layout_marginTop="@dimen/padding10dp">
<ImageView
android:id="@+id/imageViewEnterGuestRegistration"
android:layout_width="25dp"
android:layout_height="25dp"
android:adjustViewBounds="true"
android:background="@drawable/ic_create_black_48dp"
android:backgroundTint="#d50000" />
<TextView
android:id="@+id/textViewEnterGuestRegistration"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:allowUndo="false"
android:text="Upiši novog gosta"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#d50000" />
</LinearLayout>
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
这就像一个魅力,但现在,代码不会通过_Connection = new StreamingSubscriptionConnection(_Service, 30);
// Add connections to the queue
foreach (var subscription in pendingSubscribes)
{
_Connection.AddSubscription(subscription);
}
if (_Subscriptions.Count > 0) _Connection.Open();
调用某个O365邮箱恢复。所有其他测试邮箱都有效。
Stream已正确注册:
Open
然后我们打开StreamingConnection。这就是它查找工作邮箱的方式:
** EwsRequestHttpHeaders **
<Trace Tag="EwsRequestHttpHeaders" Tid="19" Time="2017-05-22 15:26:28Z">
POST /EWS/Exchange.asmx HTTP/1.1
Content-Type: text/xml; charset=utf-8
Accept: text/xml
User-Agent: ExchangeServicesClient/15.00.0913.015
Accept-Encoding: gzip,deflate
X-AnchorMailbox: mail@contoso.onmicrosoft.com
X-PreferServerAffinity: True
</Trace>
** EwsRequest **
<Trace Tag="EwsRequest" Tid="19" Time="2017-05-22 15:26:28Z" Version="15.00.0913.015">
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<t:RequestServerVersion Version="Exchange2013" />
<t:ExchangeImpersonation>
<t:ConnectingSID>
<t:SmtpAddress>mail@contoso.onmicrosoft.com</t:SmtpAddress>
</t:ConnectingSID>
</t:ExchangeImpersonation>
</soap:Header>
<soap:Body>
<m:Subscribe>
<m:StreamingSubscriptionRequest>
<t:FolderIds>
<t:DistinguishedFolderId Id="calendar">
<t:Mailbox>
<t:EmailAddress>mail@contoso.onmicrosoft.com</t:EmailAddress>
</t:Mailbox>
</t:DistinguishedFolderId>
</t:FolderIds>
<t:EventTypes>
<t:EventType>CreatedEvent</t:EventType>
<t:EventType>ModifiedEvent</t:EventType>
<t:EventType>DeletedEvent</t:EventType>
</t:EventTypes>
</m:StreamingSubscriptionRequest>
</m:Subscribe>
</soap:Body>
</soap:Envelope>
</Trace>
** EwsResponseHttpHeaders **
<Trace Tag="EwsResponseHttpHeaders" Tid="19" Time="2017-05-22 15:26:29Z">
HTTP/1.1 200 OK
Transfer-Encoding: chunked
Content-Encoding: gzip
Vary: Accept-Encoding
request-id: 6f3920a2-9fb3-4717-b966-2861eef559a4
X-CalculatedBETarget: DB5PR02MB1191.eurprd02.prod.outlook.com
X-BackEndHttpStatus: 200
X-FromBackend-ServerAffinity: True
x-EwsHandler: Subscribe
X-DiagInfo: DB5PR02MB1191
X-BEServer: DB5PR02MB1191
Cache-Control: private
Content-Type: text/xml; charset=utf-8
Set-Cookie: exchangecookie=4a58...bf16; expires=Tue, 22-May-2018 15:26:28 GMT; path=/; HttpOnly,X-BackEndOverrideCookie=DB5PR02MB1191.eurprd02.prod.outlook.com~1942062157; path=/; secure; HttpOnly
Server: Microsoft-IIS/8.5
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
X-FEServer: DB6PR0601CA0013
Date: Mon, 22 May 2017 15:26:29 GMT
</Trace>
** EwsResponse **
<Trace Tag="EwsResponse" Tid="19" Time="2017-05-22 15:26:29Z" Version="15.00.0913.015">
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<h:ServerVersionInfo MajorVersion="15" MinorVersion="1" MajorBuildNumber="1101" MinorBuildNumber="19" Version="V2017_04_14" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" />
</s:Header>
<s:Body>
<m:SubscribeResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<m:ResponseMessages>
<m:SubscribeResponseMessage ResponseClass="Success">
<m:ResponseCode>NoError</m:ResponseCode>
<m:SubscriptionId>JwBk...iMM=</m:SubscriptionId>
</m:SubscribeResponseMessage>
</m:ResponseMessages>
</m:SubscribeResponse>
</s:Body>
</s:Envelope>
</Trace>
响应正文不会立即返回,因为连接保持打开状态。
但是,对于非工作邮箱,Response Http Headers根本不会回来。
可能导致此问题的原因是什么? API不应该返回有效数据或错误消息吗?