introduction this article describes a design and implementation (c#) of the remoting over internet using the web service as a gateway into the remoting infrastructure. the web service gateway (custom remoting channel) allows to enhance the remoting channel over internet and its chaining with another heterogeneous channel. consuming a remote object over internet is full transparently and it doesn't require any special implementation from the remoting via intranet. the web service gateway enables to create a logical model of the connectivity between the different platforms and languages. before than we will go to its implementation details, let's start it with usage and configuration issue. for some demonstration purpose i will use a msmq custom remoting channel (msmqchannellib.dll), which i described in my previously article [][1]#[1]]1]. i am assuming that you have a knowledge of the .net remoting and web service. usage consuming a remote object over internet using the web service gateway is very straightforward and it actually requires only to install the following assemblies:
webservicechannellib , this is a custom remoting channel on the client side to forward a remoting message to the web service gateway over internet (outgoing message).
webservicelistener, this is a web service (gateway) to listen an incoming message from the client side and forward it to the local remoting infrastructure (incoming message).
note that the above assemblies have to be installed (into the gac) both on the server and client sides when a remote callback is used. the next step is to configure a server and client host sides. their configuration are depended from the actually application. let me assume, we want to call a remote object driven by msmq custom channel over internet. their config files might look like the following snippets: server.exe.config <configuration> <system.runtime.remoting> <application > <service> <wellknown mode="singleton" type="myremoteobject.remoteobject, myremoteobject" objecturi="endpoint" /> </service> <channels> <channel type="rkiss.msmqchannellib.msmqreceiver, msmqchannellib" listener="./reqchannel"/> <channel type="system.runtime.remoting.channels.tcp.tcpchannel, system.runtime.remoting" port="8090" /> </channels> </application> </system.runtime.remoting> </configuration> the above server config file will register two channels to listen an incoming message for the remote well known singleton object. client.exe.config this is an example of the client config file to register our custom remoting channel. <configuration> <system.runtime.remoting> <application> <client > <wellknown type="myremoteobject.remoteobject, remoteobject" url="ws://localhost/webservicelistener/listener.asmx; tcp://localhost:8090/endpoint/remoteobject" /> </client> <channels> <channel type="rkiss.webservicechannellib.sender, webservicechannellib" mode="soap"/> </channels> </application> </system.runtime.remoting> </configuration> the ws is a custom remoting client channel to dispatch an imessage over internet using a binary respectively soap mode formatter. note that the mode is a customchannelproperty and its default value is binary. web.config this is a web service config file. the following snippet is its part. the web service gateway is also a local remoting client, therefore a client (sender) channel is requested to be registered. the following snippet shows a configuration of the two channels - tcp and msmq. <system.runtime.remoting> <application > <channels> <channel type="system.runtime.remoting.channels.tcp.tcpchannel, system.runtime.remoting"/> <channel type="rkiss.msmqchannellib.msmqsender, msmqchannellib" respond="./rspchannel" admin="./adminchannel" timeout="30" priority="10"/> </channels> </application> </system.runtime.remoting> activating a remote object the well known remote object (wko) is activated by its consumer using the getobject method mechanism. the proxy is created based on the remote object metadata assembly installed in the gac (see an argument objecttype). the remoting channel is selected by the objecturl argument. the url address in this solution has two parts :
connectivity to the web service gateway over internet
connectivity to the remote object over intranet within the web service gateway
between the primary and secondary addresses is a semicolon delimiter as it is shown the below: string objecturl = @"ws://localhost/webservicelistener/listener.asmx; msmq://./reqchannel/endpoint"; using this objecturl design pattern allows an easy selection of the web service gateways on the internet. note that the ws custom remoting channel will trim this primary address and forward only its secondary part. in this solution, the objecturl represents a physical path of the logical connectivity between the consumer and remote object regardless of how many channels are needed. in this example, the web service gateway resides on the localhost and it should be replaced by the real machine name. finally, the following code snippet shows an activation of the remote object: // activate a remote object type objecttype = typeof(myremoteobject.remoteobject); string objecturl = @"ws://localhost/webservicelistener/listener.asmx; msmq://./reqchannel/endpoint"; remoteobject ro = (remoteobject)activator.getobject(objecttype, objecturl); note that a metadata (assembly) of the remote object must be installed into the gac in the places such as client, web service gateway and server host. that's all for the client/remoteobject plumbing issue over the internet. the following pictures shows this connectivity:
now, to understand how the message flows between the heterogeneous channels over the internet, have a look at the following paragraphs: