Autor Beitrag
bennixview
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 27

Win Linux
Delphi Kylix
BeitragVerfasst: Mo 14.06.04 13:46 
Hi,

kennt sich jemand mit dem Thema WebDav aus?
Ich schreibe gerade ein kleines Programm welches WebDav ressourcen benutzen soll.
Eine Connection auf test.webdav.org habe ich bereits hinbekommen. Dazu nutze ich den Indy TCPClient. Wie gehts weiter? ich möchte z.B. den Inhalt der Ressource sehen oder etwas anlegen. Welche möglichst einfach gehaltenen statements benötige ich?
maxk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1696
Erhaltene Danke: 1

Win XP, Debian Lenny
Delphi 6 Personal
BeitragVerfasst: Mo 14.06.04 14:30 
Handelt es sich bei WebDav um das neue Mailsystem, welches IMAP ablösen soll?

_________________
Ein Computer wird das tun, was Du programmierst - nicht das, was Du willst.
espen
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 90
Erhaltene Danke: 1


D6 Prof./D7 Prof. MSSQL, MySQL
BeitragVerfasst: Mo 14.06.04 14:31 
Hi,

google mal nach xmlHttp, MSXML2_TLB. Mein WEBDAV-Client greift allerdings auf die msxml4.dll zu. Also nix mit Indy. (Hier auch ein Beispiel: www.delphipages.com/...etaildocs.cfm?ID=89) und selbstverständlich die RFC: www.webdav.org/

Gruss, Espen
bennixview Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 27

Win Linux
Delphi Kylix
BeitragVerfasst: Di 15.06.04 09:25 
Hi,

danke erst mal :-)
Den Link mit der Hotmail Anleitung kenne ich bereits aber ich werd mal versuchen da noch mehr Informationen rauszufinden.

Ich wollte eigentlich ein allgemeines Beispiel für die Kommunikation mit dem Protokoll, denn da bin ich noch nicht wirklich durchgestiegen, aber vieleicht klappts ja wenn ich die Beispiele mal ganz durcharbeite.

THX All
espen
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 90
Erhaltene Danke: 1


D6 Prof./D7 Prof. MSSQL, MySQL
BeitragVerfasst: Fr 18.06.04 13:32 
Hi,
hier mal ein kleines Beispiel, wie Du die komplette Verzeichnisstruktur einlesen kannst.
(Ist schnell hingetippt aber Ausbaufähig :wink: )

procedure WEBDAV_GetContent
const
REQUEST_TEXT = '<?xml version="1.0" encoding="utf-8"?><D:propfind xmlns:D="DAV:"><D:allprop/></D:propfind>';

var
aServerFile : String;
xmlHttp : TServerXMLHTTP40;
intHTTPStatus : Integer;
begin
// ****
// **** Verzeichnis einlesen
// ****
xmlHttp := TServerXMLHTTP40.Create(nil);
xmlHttp.open('PROPFIND', 'https://mediacenter.gmx.net', True, 'Username', 'Kennwort');
xmlHttp.setRequestHeader('Depth', 'infinity');
xmlHttp.setRequestHeader('Content-Length', IntToStr(Length(REQUEST_TEXT)));
xmlHttp.setRequestHeader('Content-type', 'text/xml');
xmlHttp.setRequestHeader('Cache-Control', 'no-cache, max-age=0, Expires=-1, Buffer=True');
xmlHttp.setRequestHeader('pragma', 'no-cache');

try
intHTTPStatus := 1;
xmlHttp.send(REQUEST_TEXT);
while intHTTPStatus <> 4 do
begin
intHTTPStatus := xmlHttp.readyState;
Application.ProcessMessages
end;
except
on E: Exception do
begin
showmessage(e.Message);
end;
end;
showmessage(xmlHttp.responseText);
xmlHttp.Disconnect();
end;
bennixview Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 27

Win Linux
Delphi Kylix
BeitragVerfasst: Di 22.06.04 10:24 
Hi,

und wenn ich ne Datei runterlade und diese dan speichern möchte ????
Ich könnte nen kleinen Denkanstoß gebrauchen. Habs schon mit dem Adodb.Stream versucht hat aber nicht geklappt.


FXMLHTTP.open('GET', 'http://test.webdav.org/dav/' + aRemoteSource, False, User, Password);
FXMLHTTP.setRequestHeader('GET', '/dav/' + aRemoteSource + ' HTTP/1.1');
FXMLHTTP.setRequestHeader('User-Agent', 'TArcWebDavMgr (compatible; MSIE 6.0; Mozilla 1.0)');
FXMLHTTP.setRequestHeader('Host', 'test.webdav.org');
FXMLHTTP.setRequestHeader('Depth', 'infinity');
FXMLHTTP.setRequestHeader('Content-Type', 'text/xml');

FXMLHTTP.send;

Und dann ???
espen
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 90
Erhaltene Danke: 1


D6 Prof./D7 Prof. MSSQL, MySQL
BeitragVerfasst: Di 22.06.04 12:10 
Hi,
natürlich geht das auch mit dem ADODB-Stream. Um Resourcen zu sparen tut's aber auch ein Memory-Stream.
Wenn Du also wie oben beschrieben dein 'GET' abgesetzt hast, Steht in responseBody der Inhalt der Datei (Variant). Probiere mal folgendes (so ungefähr :wink: )

FXMLHTTP.open('GET', 'http://test.webdav.org/dav/' + aRemoteSource, False, User, Password);
FXMLHTTP.setRequestHeader('Content-Type', 'application/octet-stream');
FXMLHTTP.setRequestHeader('pragma', 'no-cache')

FXMLHTTP.send

...

memstream := TMemoryStream.Create;
try
VariantToStream(FXMLHTTP.responseBody, memstream);
memstream.SaveToFile('C:\blablabla.xyz');
Result := True;
finally
memstream.Free;
end;

...

// Diese Prozedur wandelt ein Variant in einen MemStream (ist von www.swissdelphicenter.ch/de/

procedure VariantToStream (const variant : OleVariant; var memstream : TMemoryStream);
var
p : pointer;
begin
memstream.Position := 0;
memstream.Size := VarArrayHighBound (variant, 1) - VarArrayLowBound (variant, 1) + 1;
p := VarArrayLock (variant);
memstream.Write (p^, memstream.Size);
VarArrayUnlock (variant);
memstream.Position := 0;
end;

Gruss, Espen
bennixview Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 27

Win Linux
Delphi Kylix
BeitragVerfasst: Mi 23.06.04 10:20 
Hi,

Alles SUPER!!! ;-)

THX
maxk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1696
Erhaltene Danke: 1

Win XP, Debian Lenny
Delphi 6 Personal
BeitragVerfasst: Mi 23.06.04 23:27 
Hey, wenn ihr das nächste mal Source postet, verwendet bitte die [Delphi ]-Tags, die machen es für Leute wie mich, die sich mit der Materie bissher kaum beschäftig haben, westentlich einfacher zu lesen.

_________________
Ein Computer wird das tun, was Du programmierst - nicht das, was Du willst.