日期:2012-09-30 浏览次数:20424 次
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; }}
[assembly: ApplicationActivation(ActivationOption.Server, SoapVRoot="CSSoapSQL")]
mon = "soap:wsdl=http://jnoss3/sctrans/SCTrans.SCTransSQLNC.soap?WSDL"WScript.Echo(mon)for i = 1 to 2 set c = GetObject(mon) for j = 1 to 10 WScript.Echo i & " " & j & " " & c.CountUp("SCWKONC") nextnext
C:\moniker>actscwkoMicrosoft (R) Windows Script Host Version 5.6Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.soap:wsdl=http://jnoss3/sctrans/SCTrans.SCTransSQLNC.soap?WSDL1 1 486 NC 6e41f32f-74be-45f0-94c0-989e7e1c5672 1 2 487 NC 6e41f32f-74be-45f0-94c0-989e7e1c5672 1 3 488 NC 6e41f32f-74be-45f0-94c0-989e7e1c5672 1 4 489 NC 6e41f32f-74be-45f0-94c0-989e7e1c5672 1 5 490 NC 6e41f32f-74be-45f0-94c0-989e7e1c5672 1 6 8 NC af26b53b-4a1f-48c8-8880-518c2b55a7ce 1 7 9 NC af26b53b-4a1f-48c8-8880-518c2b55a7ce 1 8 10 NC af26b53b-4a1f-48c8-8880-518c2b55a7ce 1 9 494 NC 6e41f32f-74be-45f0-94c0-989e7e1c5672 1 10 495 NC 6e41f32f-74be-45f0-94c0-989e7e1c5672 2 1 13 NC af26b53b-4a1f-48c8-8880-518c2b55a7ce 2 2 14 NC af26b53b-4a1f-48c8-8880-518c2b55a7ce 2 3 15 NC af26b53b-4a1f-48c8-8880-518c2b55a7ce 2 4 499 NC 6e41f32f-7