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

首頁 > 開發 > XML > 正文

COM+ Web 服務:通過復選框路由到 XML Web Services (轉)5

2024-09-05 20:55:55
字體:
來源:轉載
供稿:網友

在圖 3 所示的 com+ 應用程序導出向導中,輸入代理 .msi 文件的位置和名稱。


  1. 在圖 3 所示的 com+ 應用程序導出向導中,輸入代理 .msi 文件的位置和名稱。

    圖 3:com+ 應用程序導出向導
  2. 將代理 .msi 文件安裝在單獨的客戶端計算機上,作為預先生成的 com+ 應用程序。
    安裝時將對代理進行適當的配置,以便通過 soap 訪問正確的服務器和虛擬根。對于客戶端激活,可以不使用 wsdl 名字對象,而使用常規非托管的 com+ 激活(例如,cocreateinstancecreateobject 等)。在服務器上創建并在單獨的客戶端計算機上安裝上述 visual basic 計算器示例的應用程序代理后,以下 vbscript 將通過 soap 訪問該服務器:
    set c = createobject("vb6soap.calc")for i = 1 to 10 wscript.echo i & " " & c.add(i,i) & " " & timenext 

    如果代理程序沒有啟用 com+ web 服務,則上述 vbscript 代碼將使用 dcom 訪問服務器應用程序。

事務性組件示例


簡單的計算器遠算不上工作量繁重的業務應用程序,因此我們現在考慮帶有對象池的適于 com+ 事務性組件的應用程序。
最容易管理和配置的組件是由 servicedcomponent 導出的托管代碼組件,如以下 c# 示例所示:
using system;using system.reflection;using system.runtime.interopservices;using system.enterpriseservices;using system.data;using system.data.sqlclient;[assembly: applicationname("sctrans")][assembly: applicationactivation(activationoption.server,    soapvroot="sctrans")][assembly: assemblykeyfile("sctrans.snk")]namespace sctrans{  public interface isctrans  {   string countup (string key);  }  [objectpooling(minpoolsize=0, maxpoolsize=25)]  [justintimeactivation(true)]  [classinterface(classinterfacetype.autodual)]  [transactionattribute(transactionoption.requiresnew)]  public class sctranssqlnc : servicedcomponent, isctrans  {   [autocomplete]   public string countup (string key)   {      _command = new sqlcommand("", _connection);      _command.commandtype = commandtype.text;      _command.connection.open();     _command.commandtext = "update callcount with (rowlock) set       callcount = callcount + 1 where machine='" + key + "'";     _command.executenonquery();      _command.connection.close();     _numcalls++;     return (_numcalls + " nc " + _guid);   }    protected override bool canbepooled()   {     return true;    }   private int _numcalls = 0;   private string _guid = guid.newguid().tostring();   private sqlconnection _connection =    new sqlconnection("user id=myuser;password=my!password;   database=soaptest;server=myserver");   private sqlcommand _command;      }}

圖 3:com+ 應用程序導出向導

將代理 .msi 文件安裝在單獨的客戶端計算機上,作為預先生成的 com+ 應用程序。
安裝時將對代理進行適當的配置,以便通過 soap 訪問正確的服務器和虛擬根。對于客戶端激活,可以不使用 wsdl 名字對象,而使用常規非托管的 com+ 激活(例如,cocreateinstance、createobject 等)。在服務器上創建并在單獨的客戶端計算機上安裝上述 visual basic 計算器示例的應用程序代理后,以下 vbscript 將通過 soap 訪問該服務器:

set c = createobject("vb6soap.calc")
for i = 1 to 10
wscript.echo i & " " & c.add(i,i) & " " & time
next

如果代理程序沒有啟用 com+ web 服務,則上述 vbscript 代碼將使用 dcom 訪問服務器應用程序。

事務性組件示例
簡單的計算器遠算不上工作量繁重的業務應用程序,因此我們現在考慮帶有對象池的適于 com+ 事務性組件的應用程序。

最容易管理和配置的組件是由 servicedcomponent 導出的托管代碼組件,如以下 c# 示例所示:

using system;
using system.reflection;
using system.runtime.interopservices;
using system.enterpriseservices;
using system.data;
using system.data.sqlclient;

[assembly: applicationname("sctrans")]
[assembly: applicationactivation(activationoption.server,
   soapvroot="sctrans")]
[assembly: assemblykeyfile("sctrans.snk")]
namespace sctrans
{
  public interface isctrans
  {
   string countup (string key);
  }

  [objectpooling(minpoolsize=0, maxpoolsize=25)]
  [justintimeactivation(true)]
  [classinterface(classinterfacetype.autodual)]
  [transactionattribute(transactionoption.requiresnew)]
  public class sctranssqlnc : servicedcomponent, isctrans
  {
   [autocomplete]
   public string countup (string key)
   {
      _command = new sqlcommand("", _connection);
      _command.commandtype = commandtype.text;
      _command.connection.open();
     _command.commandtext = "update callcount with (rowlock) set
      callcount = callcount + 1 where machine='" + key + "'";
     _command.executenonquery();
      _command.connection.close();
     _numcalls++;
     return (_numcalls + " nc " + _guid);
   }

   protected override bool canbepooled()
   {
     return true;
   }
   private int _numcalls = 0;
   private string _guid = guid.newguid().tostring();
   private sqlconnection _connection =
   new sqlconnection("user id=myuser;password=my!password;
   database=soaptest;server=myserver");
   private sqlcommand _command;
   
  }
}

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 曲阳县| 诸暨市| 江陵县| 岱山县| 沽源县| 甘孜县| 新和县| 栾川县| 彝良县| 梁山县| 黄龙县| 昌黎县| 宁河县| 沁阳市| 苍梧县| 田林县| 丹巴县| 翁源县| 普宁市| 嵊州市| 满城县| 忻州市| 察隅县| 伊川县| 商都县| 外汇| 邵东县| 西峡县| 朔州市| 潍坊市| 白河县| 桃园县| 绍兴市| 呼玛县| 长垣县| 昌江| 应城市| 宜兰县| 肃宁县| 乐至县| 通化市|