About TIdHTTP... - Programmers Heaven

Howdy, Stranger!

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

Categories

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.