Article View: borland.public.cppbuilder.internet.web
Article #229Re: IdHTTP Get with XML
From: Stephen
Date: Mon, 30 Jul 2007 19:21
Date: Mon, 30 Jul 2007 19:21
76 lines
2972 bytes
2972 bytes
Thanks for replying Remy, and I apologize for showing my ignorance. I know
next to nothing about making internet requests.
I've changed the code as you indicated and now get "Connection closed
gracefully" but never get a string (XML) value back. Any idea why? I've
passed a TStringStream as a second parameter. the working portion of my
code now looks like...
TStringStream *out = new TStringStream("");
http->Get(sString, out);
ShowMessage(out->DataString);
but it's crashing right after the get request.
Thanks again Remy.
Stephen
"Remy Lebeau (TeamB)" <no.spam@no.spam.com> wrote in message
news:46ae1bca$1@newsgroups.borland.com...
>
> "Stephen" <susreyNOSPAM.excite.com> wrote in message
> news:46ae0187$1@newsgroups.borland.com...
>
>> when I attempt to programatically get the data, I fail.
>
> That is because you are not sending the request correctly, as the server
> is
> telling you.
>
>> My URL is (user ID changed):
> <snip>
>
> You should be encoding that URL before passing it to Get().
>
>> My code is:
>>
>> AnsiString sString = "?API=Verify&XML=<?xml
> <snip>
>
> You are not including the full URL address in that string, only the query
> portion. You must provide the full URL.
>
>> http->Request->ContentType = "text/xml";
>
> You are sending the XML through the URL itself, not through a post stream,
> so the ContentType is meaningless in this case.
>
>
> Try this instead:
>
> AnsiString sString =
> "http://testing.shippingapis.com/ShippingAPITest.dll?API=Verify&XML=<?xml
> version=\"1.0\"?><AddressValidateRequest USERID=\"999xxxxx9999\"><Address
> ID=\"0\"><Address1></Address1><Address2>6406 Ivy
> Lane</Address2><City>Greenbelt</City><State>md</State><Zip5>74429</Zip5><Zip
> 4></Zip4></Address></AddressValidateRequest>";
>
> sString = TIdURI::URLEncode(__classid(TIdURI), sString);
>
> TIdHTTP* http = new TIdHTTP(NULL);
> try
> {
> ShowMessage(http->Get(sString));
> }
> __finally {
> delete http;
> }
>
>
> Gambit
>
>
Technical Details
Message-ID:
<46ae3a31$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<46ae0187$1@newsgroups.borland.com> <46ae1bca$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: feeec,e5404376e6a3e175 X-Google-Attributes: gidfeeec,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: "Stephen" <susreyNOSPAM.excite.com> Newsgroups: borland.public.cppbuilder.internet.web References: <46ae0187$1@newsgroups.borland.com> <46ae1bca$1@newsgroups.borland.com> Subject: Re: IdHTTP Get with XML Date: Mon, 30 Jul 2007 14:21:18 -0500 Lines: 78 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.3790.3959 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.4073 X-RFC2646: Format=Flowed; Original NNTP-Posting-Host: 72.16.12.137 Message-ID: <46ae3a31$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1185823281 72.16.12.137 (30 Jul 2007 12:21:21 -0700) Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail