Writing stream data & XML data to TIdTCPClient and TIdIOHandlerStream (Delphi 2006 & Indy10)
Posted on 2006-06-17
I am trying to implement a client connection to a server (TCP). I know the server is working because there's a VB app that makes an XMLQuery and receives a response.
I need to do the same with my Delphi 2006 Architect & Indy 10 application. Assume I know VERY little in this area and you will be close to the truth.
I was told by the folks who have the XML database server that I first have to send the size of the query in network byte order, get an Ack or Nak back, then send the query itself, and then I'll get an Ack or Nak, then the actual XML response. I'm getting an AV on the first IOHandlerStream.Write. Obviously, I don't understand what I'm doing. This must be installed later today. HELP!!
Here's my code in the FormActivate event.
procedure TForm1.FormActivate(Sender: TObject);
pLong, pXML: PChar;
with Client do
sXML := '<?xml version="1.0" encoding="UTF-8"?>' + #13#10 +
' <PublicSafetyEnvelope version="1.0">' + #13#10 +
' <MessageIdentification/> <From/> <To/> <Creation/>' + #13#10 +
' <PublicSafety id="">' + #13#10 +
' <Query>' + #13#10 +
' <MainNamesTable>' + #13#10 +
' <NameNumber search_type="equal_to">9</NameNumber>' + #13#10 +
' </MainNamesTable>' + #13#10 +
' </Query>' + #13#10 +
' </PublicSafety>' + #13#10 +
pXML := PChar(sXML);
iSize := SizeOf(pXML);
iLong := htonl(iSize);
pLong := PChar(iLong);
s := IOHandlerStream.ReadLn;