Click here to Skip to main content
Click here to Skip to main content

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

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)
{
    //    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

About the Author

carlosmsr
Architect
Argentina Argentina
No Biography provided

Comments and Discussions

 
GeneralSame here :-) PinsitebuilderUwe Keim7-Jul-07 8:05 
GeneralRe: Same here :-) PinmemberMichael Sync8-Jul-07 0:05 
Smile | :) you guys have the same idea.
 
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
 
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. Smile | :)

GeneralRe: Same here :-) Pinmembercarlosmsr14-Jul-07 4:13 

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

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

| Advertise | Privacy | Mobile
Web02 | 2.8.140721.1 | Last Updated 7 Jul 2007
Article Copyright 2007 by carlosmsr
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid