I have a very interesting issue when I call a SOAP method with my client, I must pass a parameter which is of type Array_Of_Int(Array_Of_Int = array of Integer), the problem is that when the array is being generated in the request, it generates the following
<ArrayParam>
<item>12345</item>
<item>23456</item>
<item>34567</item>
</ArrayParam>
but I believe the server expects
<ArrayParam>12345</ArrayParam>
<ArrayParam>23456</ArrayParam>
<ArrayParam>34567</ArrayParam>
I'm pretty sure that Delphi has a workaround for this issue somehow in the RegisterSerializeOptions or RegisterInvokeOptions however I can't seem to find the issue, thoughts?!
Thank you all for your time, I'm using Delphi 2010.
EDIT: in order to fix this issue, as Bruneau mentioned, we need to have the following code added in the initialization section of generated .pas file:
InvRegistry.RegisterInvokeOptions(TypeInfo(<ServerInterfaceNameHere>), ioDocument);
However that imposes another issue, the namespace, as a quick and pretty elegant fix, I've added the following code in the THTTPRio's OnBeforeExecute method
procedure TMyDataModule.MyRioBeforeExecute(const MethodName: string; SOAPRequest: TStream);
procedure FixNamespaces;
var
LStrings: TStringList;
begin
LStrings := TStringList.Create;
try
SOAPRequest.Position := 0;
LStrings.LoadFromStream(SOAPRequest);
SOAPRequest.Position := 0;
SOAPRequest.Size := 0;
LStrings.Text := StringReplace(LStrings.Text, MethodName, 'NS1:' + MethodName, [rfReplaceAll]);
LStrings.Text := StringReplace(LStrings.Text, MethodName + ' xmlns', MethodName + ' xmlns:NS1', []);
LStrings.SaveToStream(SOAPRequest);
SOAPRequest.Position := 0;
finally
FreeAndNil(LStrings);
end; // tryf
end; // procedure FixNamespaces;
begin
FixNamespaces;
end;
The above is just a fix, I really hope I can find a much cleaner and elegant solution to this issue, if anyone knows, please DO post your answer.