当前位置:编程学习 > C#/ASP.NET >>

COM+ Web 服务:通过复选框路由到 XML Web Services (转)5-Web_Ser

在图 3 所示的 COM+ 应用程序导出向导中,输入代理 .msi 文件的位置和名称。
在图 3 所示的 COM+ 应用程序导出向导中,输入代理 .msi 文件的位置和名称。

图 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) & " " & 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;        }}
补充:asp.net教程,VB.Net语言 
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,