Delphi: THTTPReqResp.Execute -> the returned non English characters are unrecognizable

Hello,

I have a THTTPReqResp object and my problem is that the  returned non English characters are unrecognizable e.g. "L‘rALltsA©g". This is important since I need to parse the Xml and insert the products into database.

I tried UTF8Decode, but it doesn't work:

var
  Msg: TStringStream;
  SoapClient: THTTPReqResp;
  sXmlMsg:TStringStream;

begin

....  here I build the sXmlMsg

  SoapClient:= THTTPReqResp.Create(nil);
  try
    SoapClient.UseUTF8InHeader := True;
    SoapClient.Connect(False);
    SoapClient.URL := 'http://someweburl/server.php';
    SoapClient.InvokeOptions := [soNoValueForEmptySOAPAction];

    SoapClient.Execute(sXmlMsg, Msg);

    Msg.Position := 0;  
    Result := Msg.ReadString(Msg.Size);  // Here the non English characters are unrecognizable
 //   Result := UTF8Decode( Msg.ReadString(Msg.Size) );  // THIS DOESN'T WORK EITHER
  finally

  end;
starhuAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

rinfoCommented:
Have you looked into this code snippet.
Maybe it can solve your problem.
Despite this i do not see any thing for such behaiour from your applicaton.
procedure THTTPReqResp.Execute(const DataMsg: String; Resp: TStream);
var
  Stream: TMemoryStream;
{$IFDEF UNICODE}
  AStr: AnsiString;
{$ENDIF}
begin
{$IFDEF UNICODE}
  AStr := UTF8Encode(DataMsg);
{$ENDIF}
  Stream := TMemoryStream.Create;
  try
{$IFDEF UNICODE}
    Stream.SetSize(Length(AStr));
    Stream.Write(AStr[1], Length(AStr));
{$ELSE}
    Stream.SetSize(Length(DataMsg));
    Stream.Write(DataMsg[1], Length(DataMsg));
{$ENDIF}
    Execute(Stream, Resp);
  finally
    Stream.Free;
  end;
end;
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.