国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

Using Web Services for Remoting over the Internet.

2024-07-21 02:21:48
字體:
來源:轉載
供稿:網友
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:
 

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 罗平县| 桦南县| 轮台县| 义乌市| 天津市| 平乡县| 南澳县| 仙居县| 宜良县| 洪湖市| 中山市| 安化县| 大渡口区| 肇州县| 南投县| 宁强县| 大理市| 从化市| 仁怀市| 连江县| 台南县| 岱山县| 中方县| 定州市| 二连浩特市| 石首市| 双牌县| 蒲城县| 建平县| 会昌县| 尉氏县| 巧家县| 黄陵县| 遵义县| 绿春县| 宁远县| 特克斯县| 屏南县| 仁布县| 福清市| 澄迈县|