Ejemplo n.º 1
0
        public static void DoPubsAdHoc()
        {
            object[] o = null;
            try
            {
                // instanciate web service
                pubs_ssl_endpoint e = new pubs_ssl_endpoint();

                e.Url                 = "https://zmv92/pubs_ssl";
                e.sqlSession          = new SqlSoapHeader.sqlSession();
                e.sqlSession.initiate = true;
                //e.sqlSession.MustUnderstand = true;
                //e.sqlSession.timeout = 12;

                e.sqlSecurityValue          = new SqlSoapHeader.Security();
                e.sqlSecurityValue.Username = "******";
                e.sqlSecurityValue.Password = "******";
                //e.sqlSecurityValue.MustUnderstand = true;

                // use security of current client principal
                //e.Credentials = System.Net.CredentialCache.DefaultCredentials;

                // this works, SQL Server uses is zmv92\fred
                // user should be "sa"
                e.Credentials = new System.Net.NetworkCredential("fred", "fred", "zmv92");

                SqlParameter[] n = null;
                o = e.sqlbatch("select suser_name()", ref n);


                // process array of results
                ProcessWSResults(o);

                //Console.WriteLine(e.sqlSession.sessionId);
            }
            catch (SoapException se)
            {
                Console.WriteLine("SoapException:");
                // nothing in here
                //Console.WriteLine("Message = {0}", se.Message);
                Console.WriteLine("Code = {0}", se.Code);
                Console.WriteLine("Detail message = {0}", se.Detail.OuterXml);
            }
            catch (Exception e)
            {
                // other exceptions
                Console.WriteLine(e.Message);
                if (e.InnerException != null)
                {
                    Console.WriteLine(e.InnerException.Message);
                }
                Console.WriteLine(e.GetType().ToString());
            }
        }
Ejemplo n.º 2
0
        public static void DoPubsAdHoc()
        {
            object[] o = null;
            try
            {
                // instanciate web service
                pubs_ssl_endpoint e = new pubs_ssl_endpoint();

                e.Url = "https://zmv92/pubs_ssl";
                //e.sqlSession = new SqlSoapHeader.sqlSession();
                //e.sqlSession.MustUnderstand = true;
                //e.sqlSession.initiate = true;
                //e.sqlSession.timeout = 12;

                e.sqlSecurityValue          = new SqlSoapHeader.Security();
                e.sqlSecurityValue.Username = "******";
                e.sqlSecurityValue.Password = "******";
                //e.sqlSecurityValue.MustUnderstand = true;

                //SqlTransaction t = new SqlTransaction();
                //t.Type = SqlTransactionType.Begin;

                // use security of current client principal
                //e.Credentials = System.Net.CredentialCache.DefaultCredentials;

                // this works
                //e.Credentials = new System.Net.NetworkCredential("fred","fred","zmv92");
                e.Credentials = new System.Net.NetworkCredential("fred", "fred", "zmv92");

                // set up the parameter(s)

                /*
                 *              SqlParameter[] p = new SqlParameter[1];
                 *              p[0] = new SqlParameter();
                 *              p[0].name = "state";
                 *              p[0].Value = "OR";
                 *
                 *              // invoke parameterized query and return result(s)
                 *              o = e.sqlbatch("select * from authors where state = 'OR'", ref p);
                 */

                SqlParameter[] n = null;
                o = e.sqlbatch("select suser_name()", ref n);


                // process array of results
                ProcessWSResults(o);

                //Console.WriteLine(e.sqlSession.sessionId);
            }
            catch (SoapException se)
            {
                Console.WriteLine("SoapException:");
                // nothing in here
                //Console.WriteLine("Message = {0}", se.Message);
                Console.WriteLine("Code = {0}", se.Code);
                Console.WriteLine("Detail message = {0}", se.Detail.OuterXml);
            }
            catch (Exception e)
            {
                // other exceptions
                Console.WriteLine(e.Message);
                if (e.InnerException != null)
                {
                    Console.WriteLine(e.InnerException.Message);
                }
                Console.WriteLine(e.GetType().ToString());
            }
        }