Article View: borland.public.cppbuilder.internet.socket
Article #3610Re: Posting a XML file with HTTP
From: Remy Lebeau (TeamB)
Date: Tue, 05 Jul 2005 17:20
Date: Tue, 05 Jul 2005 17:20
43 lines
2160 bytes
2160 bytes
"Jan" <jan@jlcsoft.com> wrote in message
news:42ca6485@newsgroups.borland.com...
> HTTP->Response->ContentType = "text/xml";
You should be filling in the Request, not the Response.
> HTTP->Connect(IdTimeoutDefault);
> if (HTTP->Connected()) {
This is not the cause of the problem, but you should get rid of that code.
You are not supposed to be doing that. Post() handles that internally.
> LIpost->LoadFromFile(sSourceFile);
Rather than using a TStringList, use a TFileStream instead. Indy does extra
processing on TStrings parameters but not on TStream. Your XML is going to
get potentially messed up during the Post() if you use a TStringList.
Use this code instead:
TFileStream *LIpost;
try
{
LIpost = new TFileStream("C:\\Temp\\test.xml", fmOpenRead |
fmShareDenyWrite);
try
{
HTTP->Request->ContentType = "text/xml";
HTTP->Post(PathHttp, LIpost);
}
__finally {
delete LIpost;
}
}
catch(const Exception &e)
{
ShowMessage("Error encountered during POST: " + e.Message);
}
Gambit
Technical Details
Message-ID:
<42cac328$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.maxwell.syr.edu!border1.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!solnet.ch!solnet.ch!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<42ca6485@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,23338d9238b4b121 X-Google-Attributes: gid11508e,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> Newsgroups: borland.public.cppbuilder.internet.socket References: <42ca6485@newsgroups.borland.com> Subject: Re: Posting a XML file with HTTP Date: Tue, 5 Jul 2005 10:20:20 -0700 Lines: 45 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 NNTP-Posting-Host: 68.69.17.41 Message-ID: <42cac328$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1120584488 68.69.17.41 (5 Jul 2005 10:28:08 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.maxwell.syr.edu!border1.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!solnet.ch!solnet.ch!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail