Introduction
This solution is composed with a Webservice that works as a proxy (it receives the request, converts the content into a format that can travel through the firewall) and a client that receives the answer and converts it back to the original format.
Base64 strings are a common solution to encode binary content for transmission over networks. Where Local networks have restricted access to the Internet (usually Proxy servers and Firewalls block requests based on its content or response headers), this may let you transmit binary files with the only need of XML content allowed.
Background
Basic experience on Webservices could help a little.
Using the Code
This article will be crystal clear for anyone with a little bit of experience in C# and Webservices. No special implementation of SOAP is used and webservices are not essential for this solution. Many other ways of transmitting the base64 string could be implemented, although webservice seems to be the easiest way.
The Windows client is coded with a reference to the webservice hosted in the local host. This way the solution can be built quickly and easily, but you probably would like to point it to a webserver hosted outside the LAN where it wouldn't be blocked by the same firewall that blocks your browser.
Core Concepts
The core of the solution is the encoding of the binary content into the base64 string.
string base64string = Convert.ToBase64String(contentBytes);
The string
result of this encoding will then be converted back to a bytes array from which the binary content could be rebuilt.
byte[] contentBytes = Convert.FromBase64String(base64string);
Service Implementation
The webservice has only one method with the following structure:
public string GetBase64StringFromResource(String URI)
{
}
Running the Client
Just select the folder where you want to save your downloaded file and type the URI for the file you want to download (e.g.: http://yourhost.com/simpleApp.exe).
Notes
As this solution involves a proxy for the request (the webservice), this means that characteristics of the proxy will impact in the system performance (connection speed, process stability, response times, etc.).
Pendings
This is a very basic implementation. Currently it will present limitations on the size of the file to be retrieved (the max size in bytes should be the max value for an int
value: 2,147,483,648).
I haven't coded any support for progress notification or exception handling.
There is no support for transmitting user credentials to authenticate at the webserver or at the host of the resource.
History
- 7th July, 2007: Initial post
If feedback is provided or support requested, I'll keep working on this sample application.