Skip to content

Commit ae35331

Browse files
committed
Fix error handling value. Attachment test and mock xml soap data update
1 parent e465b97 commit ae35331

File tree

6 files changed

+37
-15
lines changed

6 files changed

+37
-15
lines changed

src/js/Core/ExchangeService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2196,7 +2196,7 @@ export class ExchangeService extends ExchangeServiceBase {
21962196
return request;
21972197
}
21982198

2199-
//ProcessHttpErrorResponse(httpWebResponse: XMLHttpRequest /*IEwsHttpWebResponse*/, webException: any): any { throw new Error("ExchangeService.ts - ProcessHttpErrorResponse : Not implemented."); }
2199+
ProcessHttpErrorResponse(httpWebResponse: XMLHttpRequest /*IEwsHttpWebResponse*/, webException: any): void { }
22002200

22012201
/**
22022202
* Sets the type of the content.

src/js/Core/Requests/ServiceRequestBase.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ export class ServiceRequestBase {
161161
//GetResponseStream(response: IEwsHttpWebResponse, readTimeout: number):any /*System.IO.Stream*/{ throw new Error("ServiceRequestBase.ts - GetResponseStream : Not implemented.");}
162162
//GetWebRequestStream(request: IEwsHttpWebRequest): any /*System.IO.Stream*/ { throw new Error("Could not implemented."); }
163163
protected ProcessWebException(webException: XMLHttpRequest): void {
164-
if (webException.response) {
164+
if (webException) {
165165
//IEwsHttpWebResponse httpWebResponse = this.Service.HttpWebRequestFactory.CreateExceptionResponse(webException);
166166
var soapFaultDetails: SoapFaultDetails = null;
167167

src/js/Core/Requests/SimpleServiceRequestBase.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ export class SimpleServiceRequestBase extends ServiceRequestBase {
5757
errorDelegate(xhrResponse.response);
5858
}
5959
}, (resperr: XMLHttpRequest) => {
60-
EwsLogging.Log("Error in calling service, error code:" + resperr.status);
60+
EwsLogging.Log("Error in calling service, error code:" + resperr.status + "\r\n" + resperr.getAllResponseHeaders());
6161
this.ProcessWebException(resperr);
62-
if (errorDelegate) errorDelegate(this.SoapFaultDetails || resperr.responseText || resperr.response);
62+
if (errorDelegate) errorDelegate(this.SoapFaultDetails || resperr);
6363
});
6464
});
6565

test/ManualLiveTesting/AttachmentTest.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ import {MockXHRData} from "../MockXHRData";
2727
.then(() => {
2828
debugger;
2929
debugger;
30-
30+
31+
var attachment = respFind.Items[0].Attachments.Items[0];
32+
3133
respFind.Items[0].Attachments.Items[0].Load().then(() => {
3234
debugger;
3335
debugger;

test/ManualLiveTesting/app.ts

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {useCustomPromise, useCustomXhr, Uri, AttendeeInfo, TimeZoneDefinition, TimeWindow, DateTime, TimeSpan, DateTimeKind, TimeZoneInfo, AvailabilityData, EmailMessageSchema, ItemSchema, AggregateType, SortDirection, AutodiscoverService, ExchangeVersion, ExchangeCredentials, ExchangeService,
2-
UserSettingName, DomainSettingName, BasePropertySet, PropertySet, EnumHelper, FolderId, WellKnownFolderName, DOMParser, ItemView, Grouping,
3-
EwsLogging, AppointmentSchema, CalendarActionResults, EwsUtilities, MeetingCancellation, MeetingRequest, MeetingResponse, Appointment, Item, StringHelper,
4-
ResolveNameSearchLocation, ExtendedPropertyDefinition, MapiPropertyType, ConflictResolutionMode, Guid, DefaultExtendedPropertySet, SendInvitationsMode, MessageBody} from "../../src/js/ExchangeWebService";
2+
UserSettingName, DomainSettingName, BasePropertySet, PropertySet, EnumHelper, FolderId, WellKnownFolderName, DOMParser, ItemView, Grouping, EmailMessage,
3+
EwsLogging, AppointmentSchema, CalendarActionResults, EwsUtilities, MeetingCancellation, MeetingRequest, MeetingResponse, Appointment, Item, StringHelper,
4+
ResolveNameSearchLocation, ExtendedPropertyDefinition, MapiPropertyType, ConflictResolutionMode, Guid, DefaultExtendedPropertySet, SendInvitationsMode, MessageBody} from "../../src/js/ExchangeWebService";
55

66
import {MockXHRApi} from "../MockXHRApi";
77
import {MockXHRData} from "../MockXHRData";
@@ -27,7 +27,22 @@ export class Greeter {
2727
var exch = new ExchangeService(ExchangeVersion.Exchange2013);
2828
exch.Credentials = new ExchangeCredentials(credentials.userName, credentials.password);
2929
exch.Url = new Uri("https://outlook.office365.com/Ews/Exchange.asmx");
30-
EwsLogging.DebugLogEnabled = true;
30+
EwsLogging.DebugLogEnabled = false;
31+
32+
var msgattach = new EmailMessage(exch);
33+
msgattach.Subject = "Dentist Appointment";
34+
msgattach.Body = new MessageBody("The appointment is with Dr. Smith.");
35+
msgattach.ToRecipients.Add("grouptest@mysupport.in")
36+
var file = msgattach.Attachments.AddFileAttachment("filename to attach.txt", "c29tZSB0ZXh0");
37+
//file.
38+
msgattach.Send().then(() => {
39+
console.log("------------");
40+
}, (ei) => {
41+
EwsLogging.Log(ei, true, true);
42+
console.log(ei.stack, ei.stack.split("\n"));
43+
console.log("------------");
44+
});
45+
return;
3146

3247
var appointment = new Appointment(exch);
3348
appointment.Subject = "Dentist Appointment";
@@ -41,7 +56,7 @@ export class Greeter {
4156
console.log(ei.stack, ei.stack.split("\n"));
4257
console.log("------------");
4358
});
44-
return;
59+
return;
4560

4661

4762
exch.TimeZoneDefinition = new TimeZoneDefinition();
@@ -58,7 +73,7 @@ return;
5873
exch.GetUserAvailability(ats, tmw, AvailabilityData.FreeBusyAndSuggestions)
5974
.then((fi) => {
6075
//console.log("------found folder------" + fi.DisplayName + "--" + WellKnownFolderName[sr.ParentFolderId.FolderName]);
61-
EwsLogging.Log(fi, true, true);
76+
EwsLogging.Log(fi, true, true);
6277
console.log("------------");
6378
}, (ei: any) => {
6479
EwsLogging.Log(ei, true, true);
@@ -75,8 +90,8 @@ return;
7590
mockXhr.responseXml = [MockXHRData.Operations.ItemOperations.FindItemRequest1ItemViewResponse];
7691
var PR_TRANSPORT_MESSAGE_HEADERS = new ExtendedPropertyDefinition(MapiPropertyType.String, 0x007D);
7792
var EX_normalized_Subject = new ExtendedPropertyDefinition(MapiPropertyType.String, 0x0E1D); //https://willcode4foodblog.wordpress.com/2012/04/14/understanding-sharing-invitation-requests-ews-managed-api-1-2-part-2/
78-
var EX_prop2 = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.InternetHeaders,"Content-Class", MapiPropertyType.String);
79-
var psPropSet = new PropertySet(BasePropertySet.IdOnly, [PR_TRANSPORT_MESSAGE_HEADERS,EX_normalized_Subject]);
93+
var EX_prop2 = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.InternetHeaders, "Content-Class", MapiPropertyType.String);
94+
var psPropSet = new PropertySet(BasePropertySet.IdOnly, [PR_TRANSPORT_MESSAGE_HEADERS, EX_normalized_Subject]);
8095
exch.FindItems(WellKnownFolderName.Inbox, new ItemView(1))
8196
.then((response) => {
8297
for (var item of response.Items) {
@@ -201,8 +216,8 @@ return;
201216
.then((fi) => {
202217
//console.log("------found folder------" + fi.DisplayName + "--" + WellKnownFolderName[sr.ParentFolderId.FolderName]);
203218
EwsLogging.Log(fi, true, true);
204-
for(var res in fi.SuggestionsResponse)
205-
console.log("------------");
219+
for (var res in fi.SuggestionsResponse)
220+
console.log("------------");
206221
}, (ei: any) => {
207222
EwsLogging.Log(ei, true, true);
208223
console.log(ei.stack, ei.stack.split("\n"));

0 commit comments

Comments
 (0)