Click here to Skip to main content
15,881,882 members
Articles / Web Development / ASP.NET

XML Serialization and Firewalls

Rate me:
Please Sign up or sign in to vote.
2.13/5 (5 votes)
7 Jul 20072 min read 28K   305   12   3
A sample on transmitting binary content over firewalls
Screenshot - SOAPTx.gif

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.

C#
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.

C#
byte[] contentBytes = Convert.FromBase64String(base64string);

Service Implementation

The webservice has only one method with the following structure:

C#
public string GetBase64StringFromResource(String URI)
{
    //    1. Retrieve at the webserver the file pointed by the URI
    //    2. Convert the content of the file to a byte array
    //    3. Encode the byte array as a base64 string
    //    4. Return the string
}

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.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Architect Carlos Salvatore
Argentina Argentina
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.
This is a Organisation (No members)


Comments and Discussions

 
GeneralSame here :-) Pin
Uwe Keim7-Jul-07 8:05
sitebuilderUwe Keim7-Jul-07 8:05 
GeneralRe: Same here :-) Pin
Michael Sync8-Jul-07 0:05
Michael Sync8-Jul-07 0:05 
GeneralRe: Same here :-) Pin
carlos@takeapps14-Jul-07 4:13
carlos@takeapps14-Jul-07 4:13 
Didn't checked it but seems that it is much more easy to sign in for a YouSendIt, while mine is a much more general and reusable approach. But keep working on it it seems that you dedicated a lot of time to elaborate it.

C.S.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.