Why are certain Delphi SOAP RTL methods OpConvert.pas deprecated if they use String instead of Stream as their XML document type?
I have a warning in my code that I cannot figure out how to remove. Method is a utility method that calls the THTTPRIO FConverter method IOPConvert.ProcessResponse
.
There are several overloads of ProcessResponse in IOPConvert, and the one declared with the parameter type InvString
because the first parameter is deprecated.
Throughout Delphi SOAP RTL, the trend has moved away from String types and towards stream types since Delphi 7 so far (Delphi XE / XE2).
Question: WHY? In this case, I can't even figure out how to transform my helper code unless I add an ugly string stream wrapper:
TRIOHelper = class helper for THTTPRIO
public
function HelperMethod(aMethName: String; aSoapString: String) : TRemotable;
end;
function TRIOHelper.HelperMethod(aMethName, aSoapString: String): TRemotable;
var
tmpString:String;
begin
//FConverter is a field in THTTPRIO
tmpStr := GrievousXmlHackery(aSoapString);
FConverter.ProcessResponse(InvString(tmpStr), IntfMD, MethMD, FContext);
...
end;
The code above the legacy call is setting up an XML document (SOAP response) and removing some of the problematic elements from the incoming stream. Yes, hack. How do I change it, and why are the lines in OpConvert bad?
I think I need to create a String Stream or Memory Stream wrapper for the tmpString? Note that in my case, the GrievousXmlHackery function removes the tag <encoding>
, if present, from SOAP for evil reasons that are not important here.
If there is something really technically WRONG with the old methods and line based apis, I'm going to put up with the warning. But if (like many places in the VCL) the deprecated warning also means "here are the dragons", I would like to know about it.
source to share
I'm not familiar with Delphi's SOAP implementation, but why can't you just use it TStringStream
instead?
function TRIOHelper.HelperMethod(aMethName, aSoapString: String): TRemotable;
var
Strm: TStringStream;
begin
//FConverter is a field in THTTPRIO
Strm := TStringStream.Create(GrievousXmlHackery(aSoapString));
// or
// Strm := TStringStream.Create('');
// Strm.DataString := GreviousXmlHackery(aSoapString);
FConverter.ProcessResponse(Strm, IntfMD, MethMD, FContext);
// Not sure if you or THTTPRIO is responsible for releasing the stream
...
end;
source to share