unit Form_Main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, InvokeRegistry, Rio, SOAPHTTPClient, StdCtrls, ComCtrls,
SOAPHTTPTrans;
type
TForm1 = class(TForm)
HTTPRIO: THTTPRIO;
btn1: TButton;
mmoLog: TMemo;
ListBox1: TListBox;
ListView1: TListView;
Edit1: TEdit;
procedure HTTPRIOAfterExecute(const MethodName: string;
SOAPResponse: TStream);
procedure btn1Click(Sender: TObject);
procedure HTTPRIOBeforeExecute(const MethodName: string;
SOAPRequest: TStream);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
uses
services, XSBuiltIns;
{$R *.dfm}
procedure TForm1.btn1Click(Sender: TObject);
var
lESB: ExchangeServicePortType;
lServerVer: ServerVersionInfo;
lReqVersion: RequestServerVersion;
lSSC: SerializedSecurityContext;
lImpers: ExchangeImpersonation;
lGetItemResponse: GetItemResponse;
lFindItem: FindItem;
lFindItemResponse: FindItemResponse;
lFindItemResponseMessage: FindItemResponseMessageType;
lCalendar: CalendarItemType;
begin
lReqVersion := RequestServerVersion.Create;
lReqVersion.Version := ExchangeVersionType.Exchange2007;
lServerVer := ServerVersionInfo.Create;
lSSC := SerializedSecurityContext.Create;
lSSC.UserSid:= 'pda2';
lImpers := ExchangeImpersonation.Create;
lImpers.ConnectingSID := ConnectingSIDType.Create;
lESB := (HTTPRIO as ExchangeServicePortType);
lFindItem := FindItem.Create;
lFindItem.CalendarView :=CalendarViewType.Create;
lFindItem.CalendarView.StartDate :=TXSDateTime.Create;
lFindItem.CalendarView.EndDate:=TXSDateTime.Create;
lFindItem.CalendarView.StartDate.XSToNative('2013-01-01T00:00:00Z');
lFindItem.CalendarView.EndDate.XSToNative('2013-12-31T00:00:00Z');
lFindItemResponse := FindItemResponse.Create;
lFindItem.ItemShape := ItemResponseShapeType.Create;
lFindItem.ItemShape.BaseShape := DefaultShapeNamesType.AllProperties;
lFindItem.ParentFolderIds := NonEmptyArrayOfBaseFolderIdsType.Create;
lFindItem.ParentFolderIds.DistinguishedFolderId := DistinguishedFolderIdType.Create;
lFindItem.ParentFolderIds.DistinguishedFolderId.Id := DistinguishedFolderIdNameType.calendar;
lFindItem.Traversal :=ItemQueryTraversalType.Shallow;
lFindItemResponse.ResponseMessages := ArrayOfResponseMessagesType.Create;
lESB.FindItem(
lFindItem,
lImpers,
lSSC, // Impersonation
'x', // MailboxCulture
lReqVersion,
lFindItemResponse,
lServerVer);
lFindItemResponse.ResponseMessages.FindItemResponseMessage :=FindItemResponseMessageType.Create;
lFindItemResponse.ResponseMessages.FindItemResponseMessage.ResponseClass := ResponseClassType.Success;
lFindItemResponse.ResponseMessages.FindItemResponseMessage.ResponseCode := ResponseCodeType.NoError;
lFindItemResponse.ResponseMessages.FindItemResponseMessage.MessageXml := MessageXml.Create;
lFindItemResponse.ResponseMessages.FindItemResponseMessage.RootFolder := FindItemParentType.Create;
lFindItemResponse.ResponseMessages.FindItemResponseMessage.RootFolder.IncludesLastItemInRange := true;
lFindItemResponse.ResponseMessages.FindItemResponseMessage.RootFolder.Items := ArrayOfRealItemsType.Create;
lFindItemResponse.ResponseMessages.FindItemResponseMessage.RootFolder.Items.Item := ItemType.Create;
lFindItemResponse.ResponseMessages.FindItemResponseMessage.RootFolder.Items.CalendarItem := CalendarItemType.Create;
Edit1.Text := FloatToStr(lFindItemResponse.ResponseMessages.FindItemResponseMessage.RootFolder.TotalItemsInView);
end;
procedure TForm1.HTTPRIOAfterExecute(const MethodName: string;
SOAPResponse: TStream);
var
TS: TStringStream;
S : String;
begin
S := MmoLog.Text + #13#10#13#10 + 'Response:' + #13#10#13#10;
TS := TStringStream.Create(S);
try
TS.Position := Length(S);
SOAPResponse.Position := 0;
TS.CopyFrom(SOAPResponse,SOAPResponse.Size);
TS.Position := 0;
MmoLog.Lines.LoadFromStream(TS);
finally
SOAPResponse.Position := 0;
TS.Free;
end;
end;
procedure TForm1.HTTPRIOBeforeExecute(const MethodName: string;
SOAPRequest: TStream);
var
TS: TStringStream;
S : String;
begin
S := MmoLog.Text + #13#10#13#10 + 'Request:' + #13#10#13#10;
TS := TStringStream.Create(S);
try
TS.Position := Length(S);
SOAPRequest.Position := 0;
TS.CopyFrom(SOAPRequest,SOAPRequest.Size);
TS.Position := 0;
MmoLog.Lines.LoadFromStream(TS);
finally
SOAPRequest.Position := 0;
TS.Free;
end;
end;
end.