Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

TByteDynArray Size Limitation?

468 views
Skip to first unread message

David Ehrlich

unread,
Feb 18, 2004, 12:49:24 PM2/18/04
to
I've written a SharePoint WebService that permits uploading of files
directly into a SharePoint repository. I'm trying to access this Web
Service from a legacy environment. So, to provide the interface, I've
written a small Delphi 7 DLL that consumes the service and exports functions
for my legacy environment to utilize.

My exported method is defined as follows:

procedure AddDocumentToLibrary(const SharePointInterfacePTR : Pointer; const
LibraryName : pChar; const Filename : pChar; const Buffer : Pointer; const
BufferSize : Cardinal; const FieldsXML : pChar);
var Bytes : TByteDynArray;
begin
SetLength(Bytes, BufferSize);
CopyMemory(Bytes, Buffer, BufferSize);

TSharePointInterface.SharePointInterface(SharePointInterfacePTR).AddDocument
ToLibrary(StrPas(LibraryName), StrPas(Filename), Bytes, StrPas(FieldsXML));
end;

The first parameter is a pointer to a Delphi object that wraps a THTTPRIO
object (previously instantiated by the legacy application via a different
call). LibraryName is the name of the repository to use within SharePoint.
Filename is the name of the file as it should be stored in SharePoint.
Buffer & BufferSize...the actual data. FieldsXML is a string containing XML
that is interpreted in the WebService to assign key-value pairs for indexed
searching.

For completeness, here's TSharePointInterface's implementation of
AddDocumentToLibrary:

procedure TSharePointInterface.AddDocumentToLibrary(const LibraryName :
String; Filename : String; Bytes : TByteDynArray; XMLFields : String);
var MyInterfaceService : MyInterfaceSoap;
begin
MyInterfaceService := (HTTPRIO as MyInterfaceSoap);
MyInterfaceService.AddFileToDocumentLibrary(LibraryName, Filename, Bytes,
XMLFields);
end;

All this works.

Until the Buffer is greater than 23334 bytes. Then it fails with the
following error message:

Project SharePointWebService.exe raised exception class ESOAPHTTPException
with message 'The action must be retried -
URL:http://servername/_vti_bin/MyInterface.asmx -
SOAPAcction:http://site.com/webservices/AddFileToDocumentLibrary'.

Any clues as to what I can do to get around this issue?

Thanks,
--David Ehrlich


David Ehrlich

unread,
Feb 18, 2004, 4:53:18 PM2/18/04
to
It turns out there's no limitation on the size of a TByteDynArray (that I've
found). However, by default THTTPReqResp will "chunk" requests of the
request size is over "MaxSinglePostSize". "MaxSinglePostSize" defaults to
32768 bytes. If over 32768, THTTPReqResp calls HttpSendRequestEx, posts the
data with multiple InternetWriteFile calls and finishes by calling
HttpEndRequest. In my case, it is the required HttpEndRequest that is
failing with the error mentioned below. If under 32768 bytes, THTTPReqResp
simply calls HttpSendRequest.

The workaround: set MaxSinglePostSize on HTTPRIO.HTTPWebNode in the
HTTPRIOBeforeExecute event to be the length of the SOAPRequest. The post is
never "chunked" and (in my case) doesn't fail. I don't like this solution
one bit. But to expedite the project I'm working on, it will have to do.

If anyone can shed some light on this error and provide a better solution,
it would be much appreciated! WININET's documentation on this is sorely
lacking. It doesn't look to be a SOAP bug in Delphi to me, but then again,
it might be. MSDN's WININET documentation is occasionally contradictory on
some of these calls.

--David


"David Ehrlich" <djeh...@hotmail.com> wrote in message
news:4033...@newsgroups.borland.com...

0 new messages