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:


type
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;
begin
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
begin
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;
end;
// end DEEPAK

3. in the procedure, after following code:

end else if Dims = 1 then
begin

add:

// DEEPAK 03.12.2004 line added

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

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

2 Comments:

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