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

services|web|xml|复选框

在图 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;
   
  }
}

以上是小编为您精心准备的的内容,在的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索string
, command
, 应用程序
, 代理
, using
system
xml web services、webservices.xml、webservices xml数据、www.webxml.com.cn、webxml.com.cn,以便于您获取更多的相关知识。

时间: 2024-08-22 15:21:57

COM+ Web 服务:通过复选框路由到 XML Web Services (转)5的相关文章

COM+ Web 服务:通过复选框路由到 XML Web Services(1) (微软中国)

services|web|xml|复选框|微软 COM+ Web 服务:通过复选框路由到 XML Web Services John Noss 和 Jonathan HawkinsMicrosoft Corporation 2001年11月 摘要:COM+ Web 服务新增了某些功能,可与 Microsoft .NET Remoting 集成,并通过 SOAP for COM+ 组件实现 XML Web Services 发布的复选框激活.本文通过几个示例介绍基本的互操作性.配置以及托管和非托管

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

services|web|xml|复选框 COM+ Web 服务:通过复选框路由到 XML Web Services John Noss 和 Jonathan HawkinsMicrosoft Corporation 2001年11月 摘要:COM+ Web 服务新增了某些功能,可与 Microsoft .NET Remoting 集成,并通过 SOAP for COM+ 组件实现 XML Web Services 发布的复选框激活.本文通过几个示例介绍基本的互操作性.配置以及托管和非托管 CO

COM+ Web 服务:通过复选框路由到 XML Web Services(3) (微软中国)

services|web|xml|复选框|微软 SOAP 与 DCOM 的局限性和区别 .NET Remoting 的目的之一是提供丰富的分布式环境,使开发人员能够在此环境中对序列化协议(格式化程序)和网络协议(频道)进行组合与匹配..NET 框架 1.0 版本中的 COM+ Web 服务仅支持一种格式化程序 (SOAP) 和一种频道 (HTTP).这并不是说其他频道和格式化程序不能使用 ServicedComponents 或 COM+,而是说没有自动配置为这些备用频道和格式化程序提供客户端和

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

services|web|xml|复选框 另一个可以自定义的区域包括客户端激活对象的生存期管理,如下例所示: <?xml version="1.0" encoding="utf-8"?><configuration> <system.runtime.remoting>  <application>   <service>    <wellknown mode="SingleCall"

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

services|web|xml|复选框 表 1:WKO 模型支持的方案 WKO 客户端 WKO 服务器 VB 6.0 或非托管 C++ VB 6.0 或非托管 C++ VB 6.0 或非托管 C++ VB .NET 或 C# VB 6.0 或非托管 C++ SOAP V1.1(在 WSDL 中描述) VB 6.0 或非托管 C++ Microsoft SOAP(ATL Server,SOAP TK) C# 或 VB .NET SOAP V1.1(在 WSDL 中描述) C# 或 VB .NET

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

services|web|xml|复选框 编译并运行此 Visual Basic .NET 应用程序,将产生与前面两个 VBScript CAO 示例相同的输出内容. 因为服务器应用程序将组件发布为 CAO 和 WKO 两种形式,所以由远程客户端选择激活方法.虽然可能只对学术研究有意义,但是单一客户端计算机确实可以使用同一组件的两种远程激活方法,访问远程服务器上同一个 SOAP 发布的虚拟根. SOAP 与 DCOM 的局限性和区别.NET Remoting 的目的之一是提供丰富的分布式环境,使

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

services|web|xml|复选框 即使在通过 SOAP 调用时,CAO 激活也会保留状态,并且允许通过 SOAP 来回传递对象引用.名称和值都保留在服务器上的类实例中,并且引用可以正确工作.这两种脚本都调用相同的编译 C# 组件,只是 .NET Remoting 激活模型不同. 除了使用 CreateObject 调用 CAO 激活外,还可以使用带有 COM+ 的名字对象,它可以提供 CAO 激活来替代 WKO(类型名称和程序集名字对象).以下脚本: '直接创建两个对象set c1=Ge

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

services|web|xml|复选框 为简单起见,上述示例全部使用 VBScript 来访问 Web 服务.其实也可以通过 SOAP WSDL 名字对象使用 Visual C+.Visual Basic 6.0.Visual Basic .NET 或 C# 进行编写.例如,Visual Basic .NET 也可以使用编译的托管代码访问同一对象,如下例所示: Imports SystemImports System.Runtime.InteropServicesModule WKOClien

COM+ Web 服务:通过复选框路由到 XML Web Services(2) (微软中国)

services|web|xml|复选框|微软 事务性组件示例简单的计算器远算不上工作量繁重的业务应用程序,因此我们现在考虑带有对象池的适于 COM+ 事务性组件的应用程序.最容易管理和配置的组件是由 ServicedComponent 导出的托管代码组件,如以下 C# 示例所示: using System;using System.Reflection;using System.Runtime.InteropServices;using System.EnterpriseServices;us