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

首頁 > 編程 > .NET > 正文

Using Web Services for Remoting over the Internet.

2024-07-21 02:21:44
字體:
來源:轉載
供稿:網友
  • decoding and de-serializing of the request message
  • invoking the remote method
  • encoding and serialization of the response message

[webmethod]
public string syncprocessmessage(string request)
{
   // request: decoding and deserializing
   byte[] reqbytearray = convert.frombase64string(request);
   memorystream reqstream = new memorystream();
   reqstream.write(reqbytearray, 0, reqbytearray.length);
   reqstream.position = 0;
   binaryformatter bf = new binaryformatter();
   imessage reqmsg = (imessage)bf.deserialize(reqstream);
   reqmsg.properties["__uri"] = reqmsg.properties["__uri2"]; // work around!!
   reqstream.close();

   // action: invoke the remote method
   string[] stype = reqmsg.properties["__typename"].tostring().split(new char[]{','}); // split typename
   assembly asm = assembly.load(stype[1].trimstart(new char[]{' '})); // load type of the remote object
   type objecttype = asm.gettype(stype[0]);                           // type
   string objecturl = reqmsg.properties["__uri"].tostring();          // endpoint
   object ro = remotingservices.connect(objecttype, objecturl);       // create proxy
   traceimessage(reqmsg);
   imessage rspmsg = remotingservices.executemessage((marshalbyrefobject)ro,
                                                     (imethodcallmessage)reqmsg);
   traceimessage(rspmsg);

   // response: encoding and serializing
   memorystream rspstream = new memorystream();
   bf.serialize(rspstream, rspmsg);
   rspstream.position = 0;
   string response = convert.tobase64string(rspstream.toarray());
   rspstream.close();

   return response;
}

[webmethod]
public string syncprocesssoapmessage(string request)
{
   imessage retmsg = null;
   string response;

   try
   {
      trace.writeline(request);

      // request: deserialize string into the soapmessage
      soapformatter sf = new soapformatter();
      sf.topobject = new soapmessage();
      streamwriter rspsw = new streamwriter(new memorystream());
      rspsw.write(request);
      rspsw.flush();
      rspsw.basestream.position = 0;
      isoapmessage soapmsg = (isoapmessage)sf.deserialize(rspsw.basestream);
      rspsw.close();

      // action: invoke the remote method
      object[] values = soapmsg.paramvalues;
      string[] stype = values[2].tostring().split(new char[]{','});
      assembly asm = assembly.load(stype[1].trimstart(new char[]{' '}));
      type objecttype = asm.gettype(stype[0]);
      string objecturl = values[0].tostring();
      realproxywrapper rpw = new realproxywrapper(objecttype, objecturl,
                                                  soapmsg.paramvalues[4]);
      object ro = rpw.gettransparentproxy();
      methodinfo mi = objecttype.getmethod(values[1].tostring());
      object retval = mi.invoke(ro, values[3] as object[]);
      retmsg = rpw.returnmessage;
   }
   catch(exception ex)
   {
      retmsg = new returnmessage((ex.innerexception == null) ?
                                           ex : ex.innerexception, null);
   }
   finally
   {
      // response: serialize imessage into string
      stream rspstream = new memorystream();
      soapformatter sf = new soapformatter();
      remotingsurrogateselector rss = new remotingsurrogateselector();
      rss.setrootobject(retmsg);
      sf.surrogateselector = rss;
      sf.assemblyformat = formatterassemblystyle.full;
      sf.typeformat = formattertypestyle.typesalways;
      sf.topobject = new soapmessage();
      sf.serialize(rspstream, retmsg);
      rspstream.position = 0;
      streamreader sr = new streamreader(rspstream);
      response = sr.readtoend();
      rspstream.close();
      sr.close();
   }

   trace.writeline(response);
   return response;
}
the implementation of the steps are depended from the type of formatter such as soapformatter or binaryformatter. the first and last steps are straightforward using the remoting namespace classes. the second one (action) for the soapformatter message needed to create the following class to obtain imessage of the methodcall:
public class realproxywrapper : realproxy
{
   string _url;
   string _objecturi;
   imessagesink _messagesink;
   imessage _msgrsp;
   logicalcallcontext _lcc;

   public imessage returnmessage { get { return _msgrsp; }}
   public realproxywrapper(type type, string url, object lcc) : base(type)
   {
      _url = url;
      _lcc = lcc as logicalcallcontext;

      foreach(ichannel channel in channelservices.registeredchannels)
      {
         if(channel is ichannelsender)
         {
            ichannelsender channelsender = (ichannelsender)channel;
            _messagesink = channelsender.createmessagesink(_url, null, out _objecturi);
            if(_messagesink != null)
               break;
         }
      }

      if(_messagesink == null)
      {
         throw new exception("a supported channel could not be found for url:"+ _url);
      }
   }
   public override imessage invoke(imessage msg)
   {
      msg.properties["__uri"] = _url; // endpoint
      msg.properties["__callcontext"] = _lcc; // caller's callcontext
      _msgrsp = _messagesink.syncprocessmessage(msg);

      return _msgrsp;
   }
}// realproxywrapper
test
i built the following package to test functionality of the webservicelistener and webservicechannellib assemblies. note that this package has only test purpose. here is what you downloaded it:
  • consoleclient, the test console program to invoke the call over internet - client machine
  • consoleserver, the host process of the myremoteobject - server machine
  • myremoteobject, the remote object - server machine
  • webservicechannellib, the custom client channel
  • webservicelistener, the web service listener  - server machine

to recompile a package and its deploying in your environment follow these notes:
  • the folder webservicelistener has to be moved to the virtual directory (inetpub/wwwroot).
  • the myremoteobject assembly has to be install into the gac on  the server machine
  • the webservicechannellib assembly has to be install into the gac on the client machine
  • (option) the msmqchannellib assembly [1] has to be install into the gac on the server machine
  • the solution can be tested also using the same machine (win2k/adv server)
  • use the echo webmethod on the test page of the webservicelistener to be sure that this service will be work  

the test case is very simple. first step is to launch the consoleserver program. secondly open the consoleclient program and follow its prompt text. if everything is going right you will see a response from the remote object over internet. i am recommending to make a first test on the same machine and then deploying over internet.
conclusion
in this article has been shown one simple way how to implement a solution for remoting over internet. i used the power of .net technologies such as soap, remoting, reflection and web service. the advantage of this solution is a full transparency between the consumer and remote object. this logical connectivity can be mapped into the physical path using the config files, which they can be administratively changed.
 
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb
日韩福利视频在线观看| 91精品国产99久久久久久| 最近免费中文字幕视频2019| 国产精品自产拍高潮在线观看| 欧美在线一区二区视频| 91视频免费在线| 欧美诱惑福利视频| 国产精品视频中文字幕91| 欧美日韩激情网| 中文字幕欧美视频在线| 亚洲人成免费电影| 亚洲第一精品自拍| 91午夜在线播放| 一区二区三区在线播放欧美| 日韩精品视频在线免费观看| 在线播放精品一区二区三区| 成人亚洲综合色就1024| 亚洲欧美日本精品| 欧美大码xxxx| 国产成人免费av电影| 久久亚洲精品一区二区| 国产不卡在线观看| 国产一区深夜福利| 超在线视频97| 色偷偷噜噜噜亚洲男人的天堂| 伊人久久综合97精品| xxav国产精品美女主播| 欧美一级视频免费在线观看| 97在线精品视频| 国产精品久久精品| 亚洲人成电影网站色| 日韩中文字幕第一页| 日本精品久久中文字幕佐佐木| 97成人精品区在线播放| 91人人爽人人爽人人精88v| 色综合伊人色综合网| 亚洲精品中文字幕女同| 91久久夜色精品国产网站| 亚洲sss综合天堂久久| 欧美日韩综合视频| 国产成人短视频| 国产精品国产三级国产aⅴ浪潮| 日韩精品在线观看网站| 日韩在线观看精品| 欧美国产日本高清在线| 色诱女教师一区二区三区| 欧美日韩免费在线| 亚洲欧美成人网| 久久久亚洲国产| **欧美日韩vr在线| 日韩av免费在线看| 欧美日韩精品在线视频| 久久国产精品网站| 黑人精品xxx一区| 国产有码在线一区二区视频| 国产精品久久久一区| 国产精品自拍视频| 久久久精品欧美| 97久久国产精品| 日韩av在线网站| 亚洲国产欧美自拍| 国产精品久久久久久久久久| 成人精品网站在线观看| 日韩精品福利在线| 成人情趣片在线观看免费| 亚洲成人网在线观看| 亚洲娇小xxxx欧美娇小| 国产乱肥老妇国产一区二| 伊人久久免费视频| 日韩av理论片| 成人国产亚洲精品a区天堂华泰| 欧美一级视频一区二区| 国产精品亚洲视频在线观看| 在线亚洲午夜片av大片| 亚洲欧洲在线播放| 亚洲伊人成综合成人网| 色小说视频一区| 亚洲国产黄色片| 日韩成人激情在线| 国产精品日韩在线观看| 久久久精品免费视频| 久久久亚洲影院你懂的| 欧美伦理91i| 欧美精品久久久久久久久久| 国产精品丝袜一区二区三区| 97超视频免费观看| 亚洲va男人天堂| 亚洲国产精品久久精品怡红院| 国产久一一精品| 九九热精品在线| 国产精品精品视频| 久久久久北条麻妃免费看| 国产一区二区美女视频| 日韩视频中文字幕| 精品国产老师黑色丝袜高跟鞋| 国产91九色视频| 91精品国产99久久久久久| 成人乱人伦精品视频在线观看| 亚洲性夜色噜噜噜7777| 日韩毛片中文字幕| 91亚洲精品在线观看| 色婷婷av一区二区三区久久| 亚洲中国色老太| 深夜福利一区二区| 欧美大片在线看免费观看| 精品国产福利视频| 日韩在线观看你懂的| 国产69精品久久久久久| 亚洲人成绝费网站色www| 久久久中精品2020中文| 欧美在线观看日本一区| 国产精品免费一区豆花| 久久精彩免费视频| 亚洲毛片在线观看.| 亚洲国产天堂久久综合网| 成人免费视频xnxx.com| 国产精品日韩在线观看| 91网站在线免费观看| 国色天香2019中文字幕在线观看| 欧美国产亚洲精品久久久8v| 日韩免费看的电影电视剧大全| 国产91在线高潮白浆在线观看| 色综合久久久888| 国产不卡精品视男人的天堂| 精品久久香蕉国产线看观看亚洲| 亚洲iv一区二区三区| 欧美高清视频一区二区| 午夜美女久久久久爽久久| 黄色精品一区二区| 欧美黄色成人网| 亚洲少妇中文在线| 精品国产老师黑色丝袜高跟鞋| 久久久精品电影| 久久成人精品视频| 97国产一区二区精品久久呦| 欧美一性一乱一交一视频| 亚洲人成自拍网站| 日韩精品中文在线观看| 日韩中文字幕免费视频| 久久久久久久国产精品视频| 欧美一区亚洲一区| 日韩av大片在线| 亚洲美女精品成人在线视频| 搡老女人一区二区三区视频tv| 亚洲人成电影网| 欧美在线视频导航| 日韩精品极品视频免费观看| 在线观看欧美www| 国产精品91在线| 亚洲国产精品免费| 久久久女人电视剧免费播放下载| 久久资源免费视频| 国模私拍视频一区| 国产精品免费一区豆花| 97涩涩爰在线观看亚洲| 成人美女免费网站视频| 欧美在线精品免播放器视频| 久久99精品视频一区97| 国产一区欧美二区三区| 成人免费xxxxx在线观看| 日韩av免费一区| 成人网在线免费看| 久久精品99久久香蕉国产色戒| 国产91精品最新在线播放|