Click here to Skip to main content
15,886,919 members
Articles / Programming Languages / C#

Using WSE-DIME for Remoting over Internet.

Rate me:
Please Sign up or sign in to vote.
4.92/5 (26 votes)
6 Jan 200311 min read 156.1K   1.8K   95  
This article describes a design and implementation of the Remoting over Internet using the Advanced Web Services Enhancements - DIME technology. This solution allows to flow the binary formatted Remoting Messages through the Web Server included uploading and downloading any types of the attachments.
using System;
using System.Diagnostics;
using System.Threading;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Messaging;
using System.Runtime.Remoting.Contexts; 
using System.Data;
using System.IO;
//
using RKiss.WebServiceRemoting;

namespace MyRemoteObject
{
	public class RemoteObject : MarshalByRefObject, IWSDimeRemoting
	{
		public RemoteObject()
		{
			Trace.WriteLine("RemoteObject ctor");
		}

		//IMyInterface
		public string Echo(int id, string msg)
		{
			string response = "";
			int filesize = 0;
			AttachmentTicket at = null;

			//exception test
			if(msg.IndexOf("throw") >= 0)
					throw new Exception("This is an Exception test");

			//Attachment
			try 
			{
				at = new AttachmentTicket();
				if(at.Items.Contains("UploadFile"))
				{
					filesize = at.Detach("UploadFile", "UploadedFile.bin");
				}
				response = string.Format("Echo: id={0}, msg={1}; upload[{2}bytes]", id, msg, filesize);
			}
			catch(Exception ex) 
			{
				response = string.Format("Echo: id={0}, msg={1}", id, msg);
			}
		
			//request to download file
			if(msg.IndexOf("download") >= 0) 
			{
				if(at == null) 
				{
					at = new AttachmentTicket(Guid.NewGuid().ToString(), "RemoteObject");
				}
				at.Attach("DownloadFile", "FileToDownload.bin");
			}
		
			Console.WriteLine(response);

			return response;
		}

		[OneWay]
		public void EchoOneWay(int id, string msg)
		{
			int filesize = 0;

			//exception test
			if(msg == "throw")
				throw new Exception("This is an Exception test");
	
			//Atatchment
			AttachmentTicket at = new AttachmentTicket();
			if(at.Items.Contains("UploadFile"))
			{
				filesize = at.Detach("UploadFile", "UploadedFile.bin");
			}
		
			string response = string.Format("Echo: id={0}, msg={1}, upload[{2}bytes]", id, msg, filesize);
			Console.WriteLine(response);
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

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
Software Developer (Senior)
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions