Easy HTTP GET from scratch?

etherealfocus

Senior member
Jun 2, 2009
488
13
81
Alright, continuing my barrage of newbish questions...

I'm trying to pull a heap of data from a distributor's web service. I can access through the browser, but with 30k items and 55 attributes each, the resulting XML file makes both Chrome and IE choke.

Here's the sample GET code:

GET /path/Inventory.asmx/Resource?CustomerNumber=string&UserName=string&Password=string&LastUpdate=string&LastItem=string&Source=string HTTP/1.1
Host: sub.domain.com
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<string xmlns="http://sub.domain.com/path/Inventory.asmx">string</string>

--------

I understand that I can run this somehow through PowerShell as per http://stackoverflow.com/questions/13935218/how-to-use-http-get-in-powershell but had some trouble adapting it to fit my needs, and I'd imagine there's an easier way to do it.

All I really need is for it to dump that huge XML file on my desktop instead of into my browser. I had a couple years of comp sci back in the day but have no web programming skills beyond HTML/CSS.

Batch script or Python maybe? I'm a complete newbie at both (my comp sci was in C and Java) but need to learn Python anyway...

Thanks guys!
 

Ken g6

Programming Moderator, Elite Member
Moderator
Dec 11, 1999
16,284
3,905
75
There's plenty of programs that do that. Curl and WGet to name two. Unless you're not allowed to install external software.
 

etherealfocus

Senior member
Jun 2, 2009
488
13
81
I'm playing with it now. There's a cool lifehacker post on it at http://lifehacker.com/161202/geek-to-live--mastering-wget that might be of interest to other curious readers.

So can I pass all the above sample code through it in a single statement? And how do I tell it where to dump the resulting XML? Sorry, I'm sure this is all covered somewhere in the manual at http://www.gnu.org/software/wget/manual/wget.html but I've checked the HTTP Options section and found nothing.

The web service supports SOAP 1.1 and 1.2, HTTP GET, and HTTP POST. Obviously I don't need POST for this, but maybe SOAP is more appropriate for my purposes...? I'm in a little over my head here. lol
 

etherealfocus

Senior member
Jun 2, 2009
488
13
81
So far no luck.

U:\>wget /path/resource.asmx/reportname&customernumber=string&username=string...&source= HTTP/1.1 subdomain.domain.com

returns a bunch of errors. The string through customernumber is an unsupported scheme, and the attributes I'm passing are unrecognized as internal or external commands.

And yes, I replaced the 'string' for each attribute with valid data. I can access the web service just fine; the output is just too big for a web browser.

I put wget in the Windows folder so it runs fine; I can access the help command and such.
 

Syran

Golden Member
Dec 4, 2000
1,493
0
76
So far no luck.

U:\>wget /path/resource.asmx/reportname&customernumber=string&username=string...&source= HTTP/1.1 subdomain.domain.com

returns a bunch of errors. The string through customernumber is an unsupported scheme, and the attributes I'm passing are unrecognized as internal or external commands.

And yes, I replaced the 'string' for each attribute with valid data. I can access the web service just fine; the output is just too big for a web browser.

I put wget in the Windows folder so it runs fine; I can access the help command and such.

Just looking at your syntax, unless you are running this on the machine it's installed on, try wget with a properly formatted web address:
wget http://subdomain.domain.com/path/resource.asmx/reportname...etc

You may also want to encapsulate it in quotes if there are any spaces in the link somewhere.
 

etherealfocus

Senior member
Jun 2, 2009
488
13
81
Alright here's the string I tried:

wget "sub.domain.com/smart.resource.asmx/name?att1=string&att2=string&att3=string"

It resolves and connects, then says:

HTTP request sent, awaiting response... 500 Internal Server Error
2013-05-08 ERROR 500: Internal Server Error.

The wget syntax looks a bit different than the distributor's example GET request. Could that be the problem?

Also, how would I specify a destination for the recieved information assuming the request was successful?
 

DaveSimmons

Elite Member
Aug 12, 2001
40,730
670
126
http://linux.die.net/man/1/wget

wget -O filename request-URL

500 Internal Server Error - this means the ASPX server either didn't like the request, or more likely had a crash or exception.

You might still be getting the request URL wrong, such as not url-encoding / escaping special characters like space, = , ? .
 

etherealfocus

Senior member
Jun 2, 2009
488
13
81
@Crusty I get the same error using

wget "sub.domain.com/smart.resource.asmx/name?att1=string&att2=string&att3=string" HTTP/1.1

and

wget "http://sub.domain.com/smart.resource.asmx/name?att1=string&att2=string&att3=string" HTTP/1.1

@DaveSimmons thanks for the link! Digging through it now. Question: as I understand it, the ampersands between attributes are part of the http code and shouldn't be swapped, but values including ampersands and such should. Is that correct, or should I swap everything? ie:

wget "url.com/resource.asmx/resource%3Fatt1=string%26att2=string%26att3=string..."
 

Syran

Golden Member
Dec 4, 2000
1,493
0
76
wget "http://sub.domain.com/smart.resource.asmx/name?att1=string&att2=string&att3=string" HTTP/1.1
Dumb question, is the HTTP/1.1 supposed to be part of the link somehow? If so, it should be within the quotes, if it isn't, try dropping it from the wget. You may also, if possible, try some sort of smaller query, just to see if you get any data at all, if that's possible.

@DaveSimmons thanks for the link! Digging through it now. Question: as I understand it, the ampersands between attributes are part of the http code and shouldn't be swapped, but values including ampersands and such should. Is that correct, or should I swap everything? ie:

wget "url.com/resource.asmx/resource%3Fatt1=string%26att2=string%26att3=string..."

Basically, when you put anything after a ? in a link, it's put into the GET command structure. Each comparison on it's own can be in any order, so long as the values line up correctly.

ie:
Code:
http://www.test.com/index.php?base=1&subject=test&name=whomever
http://www.test.com/index.php?subject=test&base=1&name=whomever
http://www.test.com/index.php?name=whomever&base=1&subject=test

Those would all be processed the same way by the server.
 
Last edited:

DaveSimmons

Elite Member
Aug 12, 2001
40,730
670
126
@DaveSimmons thanks for the link! Digging through it now. Question: as I understand it, the ampersands between attributes are part of the http code and shouldn't be swapped, but values including ampersands and such should. Is that correct, or should I swap everything? ie:

page ? variable1 = value1 & variable2 = value2 ...

It's only the value1, value2, ... where you need to replace (url-encode) any " " / "&"

Dumb question, is the HTTP/1.1 supposed to be part of the link somehow?

No, and I didn't see it listed in the parameters for wget, but I didn't read them all.
 

Net

Golden Member
Aug 30, 2003
1,592
2
81
any chance you cost post the link?

try this:

Code:
curl -H "Accept: text/xml" -H "Content-Type: text/xml" -X GET "http://www.w3schools.com/dom/books.xml"
 

etherealfocus

Senior member
Jun 2, 2009
488
13
81
Sadly I can't post the link - our supplier list is confidential. I did get it figured out though - pasted my wget statement into a batch file and ran it from CMD. Here's the working string:

wget "url.com/path/resource.asmx/query?att1=value1&att2=value2" HTTP/1.1

Downloaded the entire 110MB xml file.

The HTTP/1.1 thing is specified in their example. Not sure why it's formatted that way, seems weird to me too. The supplier in question is not a shining paragon of technical wizardry, to put it mildly, so they might just be using some obsolete or third party system that does things oddly.

Anyway, it works. Thanks guys!
 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |