亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb

首頁 > 編程 > .NET > 正文

Using Web Services for Remoting over the Internet.

2024-07-21 02:21:48
字體:
來源:轉載
供稿:網友


 
concept and design
concept of the remoting over internet is based on dispatching a remoting message over internet using the web service features as a transport layer. the following picture shows this solution:

client activates a remote wko to obtain its transparent proxy. during this process the custom remoting channel (ws) is initiated and inserted into the client channel sink chain. invoking a method on this proxy, the imessage is created which it represents a runtime image of the method call at the client side. this imessage is passed into the channel sink. in our solution to the custom client (sender) channel ws. this channel sink has a responsibility to convert imessage to the soapmessage in the text/xml format pattern and send it over internet to the web service gateway. the following picture shows this:

the web service gateway has two simply webmethods, one for the soapmessage format and the other one for a binary  format encoded by base64 into the text string. the first one method enables to use a call from an unknown client, as opposite in the binary formatting message for .net client.
lets continue with the imessage/soapmessage flows on the web service gateway side as it is shown on the above picture. the text/xml formatted soapmessage sent over internet might look like the following snippet:
text/xml formatted soapmessage request.
<soap-env:envelope xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"
xmlns:xsd="http://www.w3.org/2001/xmlschema"
xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"
soap-env:encodingstyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:a3="http://schemas.microsoft.com/clr/nsassem/myremoteobject/myremoteobject,
version=1.0.772.24659, culture=neutral, publickeytoken=ec0dd5142ae7a19b"
xmlns:a1="http://schemas.microsoft.com/clr/ns/system.runtime.remoting.messaging">
<soap-env:body>
<system.runtime.remoting.messaging.methodcall id="ref-1">
<__uri id="ref-2" xsi:type="soap-enc:string">msmq://./reqchannel/endpoint</__uri>

<__methodname id="ref-3" xsi:type="soap-enc:string">get_id</__methodname>

<__typename id="ref-4" xsi:type="soap-enc:string">myremoteobject.remoteobject,
myremoteobject, version=1.0.772.24659, culture=neutral,
publickeytoken=ec0dd5142ae7a19b</__typename>

<__args href="#ref-5"/>
<__callcontext href="#ref-6"/>
</system.runtime.remoting.messaging.methodcall>
<soap-enc:array id="ref-5" soap-enc:arraytype="xsd:ur-type[0]">
</soap-enc:array>
<a1:logicalcallcontext id="ref-6">
<user href="#ref-8"/>
</a1:logicalcallcontext>
<a3:user id="ref-8">
<firstname id="ref-9" xsi:type="soap-enc:string">roman</firstname>
<lastname id="ref-10" xsi:type="soap-enc:string">kiss</lastname>
</a3:user>
</soap-env:body>
</soap-env:envelope>
this string request has to be de-serialized back to the soapmessage object, which is a clone object of the sender's origin. after that, we have an enough information to perform a method call on the remote object. conversion of the soapmessage to imessage needs to use some trick, therefore there is no class in .net namespaces to do it. the trick is based on creating a realproxy wrapper using the remote object type and its endpoint url address and overriding an invoke method of  the base realproxy class. using the reflection (late binding) to invoke the remote method, the realproxy wrapper will catch the imessage before its processing in the channel sink. now, the invoke method can perform updating the imessage by original images such as locicalcallcontext and url address. after that, the imessage is the same like on the client side over internet. now it's easy to forward this imessage to the message sink calling its syncprocessmessage method. the rest is done by a remoting paradigm.  
the syncprocessmessage returns an imessage which it represents a returnmessage from the remote method. now the process is going to reverse into the text/xml format of the soapmessage response . i will skip it this process for its simplicity and i will continue on the client custom channel (ws) where a response message has been returned. before that, have a look the text/xml formatted soapmessage response how it has been sent back to the custom channel over internet:
text/xml formatted soapmessage response.
<soap-env:envelope xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"
xmlns:xsd="http://www.w3.org/2001/xmlschema"
xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"
soap-env:encodingstyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:a3="http://schemas.microsoft.com/clr/nsassem/myremoteobject/myremoteobject,
version=1.0.772.24659, culture=neutral, publickeytoken=ec0dd5142ae7a19b"
xmlns:a1="http://schemas.microsoft.com/clr/ns/system.runtime.remoting.messaging">
<soap-env:body>
<a1:methodresponse id="ref-1">
<__uri xsi:type="xsd:ur-type" xsi:null="1"/>
<__methodname xsi:type="xsd:ur-type" xsi:null="1"/>
<__methodsignature xsi:type="xsd:ur-type" xsi:null="1"/>
<__typename xsi:type="xsd:ur-type" xsi:null="1"/>
<__return xsi:type="xsd:int">0</__return>
<__outargs href="#ref-2"/>
<__callcontext href="#ref-3"/>
</a1:methodresponse>
<soap-enc:array id="ref-2" soap-enc:arraytype="xsd:ur-type[0]">
</soap-enc:array>
<a1:logicalcallcontext id="ref-3">
<user href="#ref-5"/>
</a1:logicalcallcontext>
<a3:user id="ref-5">
<firstname id="ref-6" xsi:type="soap-enc:string">roman</firstname>
<lastname id="ref-7" xsi:type="soap-enc:string">kiss</lastname>
</a3:user>
</soap-env:body>
</soap-env:envelope>
the result of the remoting call has to be de-serialized into the soapmessage and then an imessage can be generated by the function returnmessage. this imessage is returned back to the remoting client infrastructure. in this point, the process of the remoting over internet is done and the rest is a regular remoting mechanism.  
as i mentioned earlier, the web service gateway has two methods, one has been described the above using the soapformatter and the other one is using a binaryformatter.
using the binary formatted message.
the .net clients can use a remoting over internet in more efficient (faster) way using the binaryformatter. the design implementation is more straightforward than using the soapformatter. the imessage is serialize/deserialize by the binaryformatter to/from memory stream. than this stream image is encoded/decoded using the base64 conversion class to/from text string. note that this text string is not readable. the imessage is plugged-in into the server remoting infrastructure using the remotingservices.connect and remotingservices.executemessage functions from the remoting namespace. thanks for these functions, they really saved my time.
limitation note.
the limitation of the above solution is done by the web service functionality. you cannot handle a distributed transaction over internet. in this case, the web service gateway represents a non-transactional client and remote object is a root of the transaction.
implementation
the implementation is divided into two assemblies - custom client channel and web service gateway. their implementation is straightforward without using any third party library support. i am going to concentrate only for these parts related to the imessage processing. more details about the design and implementation of the custom remoting channel can be found it in [][1]#[1]]1].
webservicechannellib
this is a custom client channel assembly to process an outgoing remoting message over internet. the client message sink has an implementation both message processing such as syncprocessmessage and asyncprocessmessage. based on the m_mode value, the imessage can be formatted by the soapformatter or binaryformatter.
the syncprocessmessage function initiates the web service client proxy generated by the vs. there is a small modification in its constructor. this proxy is a generic for any location of the web service, that's why the url address is pass through its constructor instead of its hard coding. note that any exception will be converted into the imessage format and send back to the client.
sender:
// imessagesink (methodcall)
public virtual imessage syncprocessmessage(imessage msgreq)
{
   imessage msgrsp = null;

   try
   {
      msgreq.properties["__uri"] = m_objecturi;
      service webservice = new service(m_outpath);

      if(m_mode == "soap")
      {
         // serialize imessage into the stream (soapmessage)
         memorystream reqstream = new memorystream();
         soapformatter sf = new soapformatter();
         remotingsurrogateselector rss = new remotingsurrogateselector();
         rss.setrootobject(msgreq);
         sf.surrogateselector = rss;
         sf.assemblyformat = formatterassemblystyle.full;
         sf.typeformat = formattertypestyle.typesalways;
         sf.topobject = new soapmessage();
         sf.serialize(reqstream, msgreq);
         isoapmessage sm = sf.topobject;
         reqstream.position = 0;
         streamreader sr = new streamreader(reqstream);
         string request = sr.readtoend();
         reqstream.close();
         sr.close();

         // call web service
         string respond = webservice.syncprocesssoapmessage(request);

         // return messages
         streamwriter rspsw = new streamwriter(new memorystream());
         rspsw.write(respond);
         rspsw.flush();
         rspsw.basestream.position = 0;
         isoapmessage rspsoapmsg = (isoapmessage)sf.deserialize(rspsw.basestream);
         rspsw.close();

         if(rspsoapmsg.paramvalues[0] is exception)
         {
            throw rspsoapmsg.paramvalues[0] as exception;
         }
         else
         {
            object returnval = rspsoapmsg.paramvalues[4];
            object[] outargs = rspsoapmsg.paramvalues[5] as object[];
            logicalcallcontext lcc = rspsoapmsg.paramvalues[6] as logicalcallcontext;
            returnmessage rm = new returnmessage(
                       returnval,            //object return
                       outargs,              //object[] outargs
                       outargs.length,       //int outargscount
                       lcc,                  //logicalcallcontext callctx
                       msgreq as imethodcallmessage    //imethodcallmessage mcm
                       );
            msgrsp = rm as imessage;
         }
      }
      else
      {
         msgreq.properties["__uri2"] = m_objecturi; // workaround!
         // serialize and encode imessage
         binaryformatter bf = new binaryformatter();
         memorystream reqstream = new memorystream();
         bf.serialize(reqstream, msgreq);
         reqstream.position = 0;
         string request = convert.tobase64string(reqstream.toarray());
         reqstream.close();
         // call web service
         string respond = webservice.syncprocessmessage(request);

         // decode and deserialize imessage
         byte[] rspbytearray = convert.frombase64string(respond);
         memorystream rspstream = new memorystream();
         rspstream.write(rspbytearray, 0, rspbytearray.length);
         rspstream.position = 0;
         msgrsp = (imessage)bf.deserialize(rspstream);
         rspstream.close();
      }
   }
   catch(exception ex)
   {
      trace.writeline(string.format("client:syncprocessmessage error = {0}", ex.message));
      msgrsp = new returnmessage(ex, (imethodcallmessage)msgreq);
   }

   return msgrsp;
}

public virtual imessagectrl asyncprocessmessage(imessage msgreq, imessagesink replysink)
{
   imessagectrl imc = null;

   if(replysink == null) // onewayattribute
   {
      trace.writeline("client-[oneway]async:call");
      syncprocessmessage(msgreq);
   }
   else
   {
      trace.writeline("client-async:call");
      // spawn thread (delegate work)
      delegateasyncworker daw = new delegateasyncworker(handlerasyncworker);
      daw.begininvoke(msgreq, replysink, null, null);
   }

return imc;
}
the web service client proxy changes:
[system.web.services.webservicebindingattribute(name="servicesoap",
namespace="http:]//tempuri.org/")]
public class service : system.web.services.protocols.soaphttpclientprotocol {

   [system.diagnostics.debuggerstepthroughattribute()]
      public service(string uri) {
      this.url = uri;
   }
   ...
}   
webservicelistener
this is a web service gateway to listen a methodcall formatted into the string request. there are two different webmethods for this process: syncprocessmessage and syncprocesssoapmessage. the functions have a simple logic divided into tree steps: 
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb
日本不卡视频在线播放| 欧美日韩国产中字| 日韩免费观看在线观看| 精品中文字幕视频| 欧美精品videofree1080p| 91啪国产在线| 国产在线观看一区二区三区| 久久精品影视伊人网| 日韩电影中文字幕一区| 一区二区三区亚洲| 国产这里只有精品| 亚洲精品一区中文| 日韩av在线一区二区| 亚洲黄色免费三级| 欧美国产高跟鞋裸体秀xxxhd| 日韩成人av在线| 色综合久久久久久中文网| 国产成人自拍视频在线观看| 亚洲精品第一国产综合精品| 亚洲精品国产拍免费91在线| 久久精品国产亚洲7777| 日韩免费观看av| 51ⅴ精品国产91久久久久久| 欧美成人午夜激情| 97在线视频免费| 久久国产精品99国产精| 精品一区二区三区三区| 亚洲无av在线中文字幕| 欧美中文字幕第一页| 懂色av影视一区二区三区| 日本在线观看天堂男亚洲| 久久影视三级福利片| 国产精品男人爽免费视频1| 91精品国产91久久久久久久久| 亚洲欧美综合v| 中文字幕少妇一区二区三区| 欧美精品第一页在线播放| 欧美精品中文字幕一区| 一区二区三区www| 国产精品十八以下禁看| 国产成人一区二区三区小说| 日韩一区二区福利| 国产精品旅馆在线| 久久久精品久久| 97在线看免费观看视频在线观看| 欧美在线视频网站| 麻豆乱码国产一区二区三区| 成人在线免费观看视视频| 日韩精品在线免费播放| 精品视频9999| 亚洲xxxxx性| 欧美电影免费观看大全| 精品国产乱码久久久久久婷婷| 亚洲国产精品va| 国产精品国语对白| 91美女福利视频高清| 欧美成人四级hd版| 久久久视频在线| 91久久久久久久久久久| 亚洲午夜精品久久久久久久久久久久| 久久久久久有精品国产| 色综合天天狠天天透天天伊人| 成人福利视频在线观看| 亚洲精品国产精品久久清纯直播| 国产精品入口夜色视频大尺度| 亚洲片在线观看| 国产精品大陆在线观看| 成人伊人精品色xxxx视频| 国产999精品久久久影片官网| 国模精品一区二区三区色天香| 欧美大肥婆大肥bbbbb| 精品动漫一区二区三区| 午夜精品福利视频| 色偷偷av亚洲男人的天堂| 成人免费观看a| 亚洲理论片在线观看| 激情成人中文字幕| 亚洲欧美制服第一页| 亚洲性生活视频| 欧美高清性猛交| 国产婷婷97碰碰久久人人蜜臀| 国产视频自拍一区| 亚洲精品一区二三区不卡| 欧美日韩国产专区| 一本一道久久a久久精品逆3p| 青草青草久热精品视频在线观看| 亚洲国产成人精品久久| 亚洲成人网久久久| 操人视频在线观看欧美| 国产丝袜一区二区三区| 日本成人激情视频| 在线一区二区日韩| 黑人巨大精品欧美一区免费视频| 欧美日韩国产va另类| 成人国内精品久久久久一区| 中日韩美女免费视频网站在线观看| 精品国产一区二区三区久久狼黑人| 国产一区私人高清影院| 欧美激情一级二级| 欧美最顶级丰满的aⅴ艳星| 欧美日本黄视频| 大伊人狠狠躁夜夜躁av一区| 日韩国产中文字幕| 欧美日韩另类视频| 992tv成人免费视频| 亚洲第一级黄色片| 久久激情五月丁香伊人| 欧美最猛黑人xxxx黑人猛叫黄| 欧美成人精品在线观看| 姬川优奈aav一区二区| 91精品国产自产在线老师啪| 亚洲国产精品电影在线观看| 欧美xxxx做受欧美| 日韩中文字幕在线精品| 欧美日韩在线视频一区二区| 成人免费网视频| 欧美成人午夜激情在线| 中文字幕在线精品| 久久久国产影院| 久久精品国产成人精品| 色妞久久福利网| 国产视频精品在线| 九九热这里只有精品免费看| 国产欧美一区二区三区视频| 国产不卡在线观看| 欧美高清性猛交| 精品高清一区二区三区| 亚洲第一福利网站| 亚洲一区二区三区视频| 国产精品白丝av嫩草影院| 亚洲tv在线观看| 国产成人精品久久二区二区91| 久久久久久91香蕉国产| 国产精品成人国产乱一区| 精品久久久久久国产| 91精品在线播放| 国产精品中文字幕在线观看| 精品国产欧美成人夜夜嗨| 福利二区91精品bt7086| 国产成人拍精品视频午夜网站| 一区二区三区在线播放欧美| 97精品视频在线观看| 欧美性生交大片免费| 国产成人精品视频在线观看| 亚洲人成网站999久久久综合| zzijzzij亚洲日本成熟少妇| 欧美另类极品videosbest最新版本| 中文字幕欧美国内| 成人黄色免费网站在线观看| 欧美最猛性xxxx| 欧美日韩免费区域视频在线观看| 亚洲精品资源在线| 日韩精品视频免费在线观看| 亚洲欧美中文日韩v在线观看| 亚洲激情视频在线观看| 国产精品日日摸夜夜添夜夜av| 午夜精品福利视频| 日韩免费在线视频| 国产精品久久久久久亚洲影视| 欧美在线视频免费| 精品国产乱码久久久久久婷婷| 欧美成人免费网| 中文字幕不卡av| 国产精品久久久亚洲|