In the COM + application export wizard shown in figure 3, enter the location and name of the proxy. msi file.
In the COM + application export wizard shown in figure 3, enter the location and name of the proxy. msi file.
Figure 3: the COM + application export wizard installs the proxy. msi file on a separate client computer as a pre-generated COM + application.
During installation, the proxy is configured appropriately to access the correct server and virtual root through SOAP. For client activation, you can use a conventional unmanaged COM + activation (such as CoCreateInstance and CreateObject) instead of a wsdl name object ). After the application proxy of the preceding Visual Basic calculator example is created on the server and installed 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) & "& Timenext
If the agent does not enable the COM + Web Service, the preceding VBScript Code uses DCOM to access the server application.
Examples of transactional Components
A simple calculator is far from a heavy workload of business applications, so we now consider applications with an object pool suitable for COM + transactional components.
The most easily managed and configured component is the managed code component 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 = Comma NdType. text; _ command. connection. open (); _ command. commandText = "UPDATE CallCount WITH (ROWLOCK) SET CallCount = CallCount + 1 WHERE Machine = '" + Key + "'"; _ command. executeNonQuery (); _ command. connection. close (); _ numcballs ++; return (_ numcballs + "NC" + _ guid);} protected override bool CanBePooled () {return true ;} private int _ numcils = 0; private string _ guid = Guid. newGuid (). toString (); pr Ivate SqlConnection _ connection = new SqlConnection ("user id = MyUser; password = My! Password; database = SoapTest; server = MyServer "); private SqlCommand _ command ;}}