I have a very interesting problem, when I call the SOAP method with my client, I have to pass a parameter that is of type Array_Of_Int (Array_Of_Int = array Integer), the problem is that when the array is generated in the request, it generates the following
<ArrayParam> <item>12345</item> <item>23456</item> <item>34567</item> </ArrayParam>
but I suppose the server is expecting
<ArrayParam>12345</ArrayParam> <ArrayParam>23456</ArrayParam> <ArrayParam>34567</ArrayParam>
I'm sure Delphi has a workaround for this problem somehow in RegisterSerializeOptions or RegisterInvokeOptions, but I canβt find the problem, thoughts ?!
Thank you all for your time, I am using Delphi 2010.
EDIT: To fix this problem, as Brunau mentioned, we need to add the following code to the initialization section of the generated .pas file:
InvRegistry.RegisterInvokeOptions(TypeInfo(<ServerInterfaceNameHere>), ioDocument);
However, this poses another problem, the namespace, as a quick and fairly elegant fix, I added the following code in the THTTPRio 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;
The above solution is simple , I really hope that I can find a much cleaner and more elegant solution to this problem, if anyone knows , please post your answer .