Friday, December 03, 2004

Bug in Delphi SOAP: arrays of TByteDynarrays don't work well.

There's a bug in the Delphi SOAP source code when using parameters like:

MultiArray = array of TByteDynArray;

To fix this, first add $(DELPHI)\Source\Soap to your search path, or copy the file
OPtoSOAPDOMConv.pas to your local directory.

then modify the file as follows:

1. Locate the function ConvertSoapToNativeArrayElem.

2. add the following as a subfunction:

// DEEPAK changed 3.12.2004 fix for arrays of
// TByteDynArray
function TestDimDynArray( var Res : Pointer ) : boolean;
var ArrayLen : integer;
DynP : Pointer;
TypeURI, TYpeName : InvString;
S : string;
result := False;
GetElementType(Node, TypeURI, TypeName);
if (Dims = 1) and
((ElemInfo.Kind = tkInteger) or
(ElemInfo.Kind = tkChar)) and
(GetTypeData(ElemInfo).OrdType = otUByte) and
{ Some SOAP implementations don't
send the XML Namespace!! }
(((TypeName ='base64Binary')) or
((TypeURI = SSoap11EncodingS5) and
(TypeName = 'base64')) or
{ Some SOAP implementations don't
send the type!! }
(TypeName = '' )) then
S := DecodeString(Node.Text);
ArrayLen := Length(S);
DynP := Pointer(PInteger(DataP)^);
DynArraySetLength(DynP, TypeInfo(TByteDynArray),
1, @ArrayLen);
Move(S[1], DynP^, Length(S));
Res := DynP;
Result := True;
// end DEEPAK

3. in the procedure, after following code:

end else if Dims = 1 then


// DEEPAK 03.12.2004 line added

if not TestDimDynArray(Result) then
[ NOW put everything from
Size := ntElementChildCount(Node);
if Size > 0 then
ReadRow(RootNode, Node, CurElem,
Size, PElem, ElemInfo);
in this block]

(essentially, byte dynarrays must be handled differently, even when you
have an array of bytearrays)


Anonymous Anonymous said...

is this only when you use:
array of TByteDynArray;

or could it be affected when you are using SomeFunction:TByteDinArray by itself?

12:07 PM  
Blogger Deepak Shenoy said...

It's only when you use Array of TByteDynArray. Using TByteDynArray itself is not a problem.

11:01 PM  

Post a Comment

<< Home