The Using Web Services for Remoting over the Internet.

Source: Internet
Author: User
Tags config soap web services client msmq
Introduction
This is article describes a design and implementation (C #) of the Remoting over Internet using the Web Service as a gateway I Nto the Remoting infrastructure. The Web Service Gateway (Custom Remoting Channel) allows to enhance the Remoting Channel over Internet and its chaining WI Th another heterogeneous channel. Consuming a remote object over Internet are full transparently and it doesn ' t require any special implementation from the R Emoting via intranet. The Web Service Gateway enables to create a logical model of the connectivity between the different platforms and LANGUAG Es. Before than we'll go to its implementation details, let's start it with usage and configuration issue. For some demonstration purpose I'll 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 onl Y to install the following assemblies:
    • Webservicechannellib , this is a Custom Remoting Channel on the client side to forward a Remoting Web Service Gateway over the Internet (outgoing message).
    • Webservicelistener, this is a Web Service (gateway) to listen an incoming message from the client side and Forwar D it to the "local remoting infrastructure" (incoming message).

Note This above assemblies have to is installed (into the GAC) both on the server and client sides when a remote CALLB The ACK is used.
The next are 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 the 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 would register two channels to listen a incoming message for the remote down known singleton Object.
Client.exe.config
This is a 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 wsis a Custom Remoting Client Channel to dispatch a IMessage over Internet using a binaryrespectively SoapMode formatter. Note that the Modeis a customchannelproperty and its default value is binary.
Web.config
This is a Web Service config file. The following snippet is it part. The Web Service Gateway is also a local remoting client, therefore a client (sender) channel was 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= "priority=" "/>
</channels>
</application>
</system.runtime.remoting>
activating a remote object
The 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 (I/argument ). The remoting channel is selected by the Objecturl argument . The URLAddress in this solution has two parts:
    • Connectivity to the Web Service gateway over the 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 ";
The Using this Objecturl design pattern allows a easy selection the Web service gateways on the Internet. Note that The wsCustom Remoting channel'll 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 obj ECT regardless of how many channels are needed. In this example, the Web Service gateway resides on the localhostAnd 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 is installed into the GAC in the places such as client, Web serv Ice 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" heterogeneous channels over the Internet, have a look at the Followin G Paragraphs:





Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.