Click here to Skip to main content
13,663,132 members
Click here to Skip to main content
Add your own
alternative version


11 bookmarked
Posted 7 Jul 2007

XML Serialization and Firewalls

, 7 Jul 2007
Rate this:
Please Sign up or sign in to vote.
A sample on transmitting binary content over firewalls
Screenshot - SOAPTx.gif


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.


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)
    //    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.:


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.).


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.


  • 7th July, 2007: Initial post

If feedback is provided or support requested, I'll keep working on this sample application.


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


About the Author

Argentina Argentina
No Biography provided

You may also be interested in...

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
memberMichael Sync8-Jul-07 0:05 
GeneralRe: Same here :-) Pin
carlosmsr14-Jul-07 4:13
membercarlosmsr14-Jul-07 4:13 

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.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web01-2016 | 2.8.180810.1 | Last Updated 7 Jul 2007
Article Copyright 2007 by carlosmsr
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid