Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

About TIdHTTP...

IPOzIPOz Posts: 5Member
Hi friends,
Now i am using TIdHTTP to call a servlet which will accept and return XML data. The TIdHTTP works very well but i have question about it.

.the get methods
procedure Get(AURL: string; const AResponseContent: TStream); overload;
function Get(AURL: string): string; overload;

Parameters
AURL: string
The resource to be retrieved.

const AResponseContent: TStream
Destination for the data retrieved.

the get(AURL:string) works very well and i can get the XML data from the servlet.However if i use get(AURL:string; const AResponseContent:TStream) as below,i donot understand how to use the second parameter.
....
var
ms : TMemoryStream;
begin
ms := TMemoryStream.create;
try IdHTTP1.get('http://192.168.1.118:8080/mProject/servlet/ServiceServlet',ms);
memo1.Lines.loadFromStream(ms); <= get nothing
finally
ms.free;
end;
end;

the memo1 will not have any data :(. However the following code works very well:
...
try
memo1.Text := IdHTTP1.get('http://192.168.1.118:8080/mProject/servlet/ServiceServlet');
except
raise;
end

.the put methods
procedure Post(URL: string; const Source: TStrings; const AResponseContent: TStream); overload;

Parameters
URL: string
Location of the host or CGI application.

const Source: TStrings
Object containing the request data.

const AResponseContent: TStream
Destination for response data.

I still cannot understand how to use AResponseContent parameter to get the return data.
...
var
ms : TMemoryStream;
begin
ms := TMemoryStream.create;
try
IdHTTP1.put('http://192.168.1.118:8080/mProject/servlet/ServiceServlet2',memo1.Lines,ms)
memo2.lines.loadFromStream(ms); <= get nothing
finally
free;
end;
end;

Any suggestion is appreciated !
garbage in garbage out
Sign In or Register to comment.