COM + Web service: Routing to XML Web services by check box 5

Source: Internet
Author: User
Tags bool soap reflection tostring web services wsdl
services|web|xml| check box in the COM + Application Export Wizard shown in Figure 3, enter the location and name of the proxy. msi file.


    1. In the COM + Application Export Wizard shown in Figure 3, enter the location and name of the proxy. msi file.

      Figure 3:com+ Application Export Wizard
    2. Installs the agent. msi file on a separate client computer as a pre-generated COM + application.
      The agent is configured appropriately at installation to access the correct server and virtual root through SOAP. For client activation, you can use a generic unmanaged COM + activation (for example,CoCreateInstance,CreateObject , and so on) without using a WSDL moniker. After you create an application proxy on the server and install the above Visual Basic Calculator sample on a separate client computer, the following VBScript accesses the server through SOAP:

      If the agent does not enable COM + WEB services, the VBScript code above will use DCOM to access the server application.
Transactional Components Sample
The simple calculator is far from being a heavy workload business application, so we now consider applications with object pooling that are suitable for COM + transactional components.
The easiest components to manage and configure are the ServicedComponentExported managed code components, as shown in the following C # example:
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= ]  [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 WHE RE 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;     &NBSP}} 

Figure 3:com+ Application Export Wizard

Installs the agent. msi file on a separate client computer as a pre-generated COM + application.
The agent is configured appropriately at installation to access the correct server and virtual root through SOAP. For client activation, you can use a generic unmanaged COM + activation (for example, CoCreateInstance, CreateObject, and so on) without using a WSDL moniker. After you create an application proxy on the server and install the above Visual Basic Calculator sample on a separate client computer, the following VBScript accesses the server through SOAP:

Set C = CreateObject ("Vb6soap.calc")
For i = 1 to 10
WScript.Echo I & "" & C.add (i,i) & "" & Time
Next

If the agent does not enable COM + WEB services, the VBScript code above will use DCOM to access the server application.

Transactional Components Sample
The simple calculator is far from being a heavy workload business application, so we now consider applications with object pooling that are suitable for COM + transactional components.

The easiest components to manage and configure are managed code components that are exported by ServicedComponent, as shown in the following C # example:

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;

}
}



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.