var someFile = File('~/Documents/Foo.txt'); someFile.open('r'); var foo = someFile.read(); someFile.close();
Yes, you can using a socket. You will need to write most of a basic http protocol handler to do so. That kinda makes it way more than a code snippet. I did it for CS3 project, back in the day. Worked well enough.
You can also search the forums for loading an external web library. I don't recall the name of the lib at the moment, but it was possible to do.
If you're using CS5 and need to use web services, you really need to be using the new Creative Suite SDK and Extension Builder. That'll take days of work and turn it into hours.