Click here to Skip to main content
15,892,298 members
Articles / Web Development / ASP.NET

Developing Next Generation Smart Clients using .NET 2.0 working with Existing .NET 1.1 SOA-based XML Web Services

Rate me:
Please Sign up or sign in to vote.
4.96/5 (134 votes)
16 Aug 200540 min read 1.2M   3.9K   462  
Comprehensive guide to development of .NET 2.0 Smart Clients working with existing Service Oriented Architecture based XML web services, fully utilizing the Enterprise Library
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50215.44
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

// 
// This source code was auto-generated by Microsoft.VSDesigner, Version 2.0.50215.44.
// 
namespace SmartInstitute.Automation.SmartInstituteServices.SecurityService {
    using System.Diagnostics;
    using System.Web.Services;
    using System.ComponentModel;
    using System.Web.Services.Protocols;
    using System;
    using System.Xml.Serialization;
    
    
    /// <remarks/>
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Web.Services.WebServiceBindingAttribute(Name="SecurityServiceSoap", Namespace="http://oazabir.com/webservices/smartinstitute")]
    public partial class SecurityService : System.Web.Services.Protocols.SoapHttpClientProtocol {
        
        private CredentialSoapHeader credentialSoapHeaderValueField;
        
        private System.Threading.SendOrPostCallback AuthenticateUserOperationCompleted;
        
        private System.Threading.SendOrPostCallback ChangePasswordOperationCompleted;
        
        private bool useDefaultCredentialsSetExplicitly;
        
        /// <remarks/>
        public SecurityService() {
            this.Url = SmartInstitute.Automation.Properties.Settings.Default.SmartInstitute_Automation_SmartInstituteServices_SecurityService_SecurityService;
            if ((this.IsLocalFileSystemWebService(this.Url) == true)) {
                this.UseDefaultCredentials = true;
                this.useDefaultCredentialsSetExplicitly = false;
            }
            else {
                this.useDefaultCredentialsSetExplicitly = true;
            }
        }
        
        public CredentialSoapHeader CredentialSoapHeaderValue {
            get {
                return this.credentialSoapHeaderValueField;
            }
            set {
                this.credentialSoapHeaderValueField = value;
            }
        }
        
        public new string Url {
            get {
                return base.Url;
            }
            set {
                if ((((this.IsLocalFileSystemWebService(base.Url) == true) 
                            && (this.useDefaultCredentialsSetExplicitly == false)) 
                            && (this.IsLocalFileSystemWebService(value) == false))) {
                    base.UseDefaultCredentials = false;
                }
                base.Url = value;
            }
        }
        
        public new bool UseDefaultCredentials {
            get {
                return base.UseDefaultCredentials;
            }
            set {
                base.UseDefaultCredentials = value;
                this.useDefaultCredentialsSetExplicitly = true;
            }
        }
        
        /// <remarks/>
        public event AuthenticateUserCompletedEventHandler AuthenticateUserCompleted;
        
        /// <remarks/>
        public event ChangePasswordCompletedEventHandler ChangePasswordCompleted;
        
        /// <remarks/>
        [System.Web.Services.Protocols.SoapHeaderAttribute("CredentialSoapHeaderValue")]
        [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://oazabir.com/webservices/smartinstitute/AuthenticateUser", RequestNamespace="http://oazabir.com/webservices/smartinstitute", ResponseNamespace="http://oazabir.com/webservices/smartinstitute", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
        public string AuthenticateUser() {
            object[] results = this.Invoke("AuthenticateUser", new object[0]);
            return ((string)(results[0]));
        }
        
        /// <remarks/>
        public void AuthenticateUserAsync() {
            this.AuthenticateUserAsync(null);
        }
        
        /// <remarks/>
        public void AuthenticateUserAsync(object userState) {
            if ((this.AuthenticateUserOperationCompleted == null)) {
                this.AuthenticateUserOperationCompleted = new System.Threading.SendOrPostCallback(this.OnAuthenticateUserOperationCompleted);
            }
            this.InvokeAsync("AuthenticateUser", new object[0], this.AuthenticateUserOperationCompleted, userState);
        }
        
        private void OnAuthenticateUserOperationCompleted(object arg) {
            if ((this.AuthenticateUserCompleted != null)) {
                System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
                this.AuthenticateUserCompleted(this, new AuthenticateUserCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
            }
        }
        
        /// <remarks/>
        [System.Web.Services.Protocols.SoapHeaderAttribute("CredentialSoapHeaderValue")]
        [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://oazabir.com/webservices/smartinstitute/ChangePassword", RequestNamespace="http://oazabir.com/webservices/smartinstitute", ResponseNamespace="http://oazabir.com/webservices/smartinstitute", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
        public void ChangePassword(string newPassword) {
            this.Invoke("ChangePassword", new object[] {
                        newPassword});
        }
        
        /// <remarks/>
        public void ChangePasswordAsync(string newPassword) {
            this.ChangePasswordAsync(newPassword, null);
        }
        
        /// <remarks/>
        public void ChangePasswordAsync(string newPassword, object userState) {
            if ((this.ChangePasswordOperationCompleted == null)) {
                this.ChangePasswordOperationCompleted = new System.Threading.SendOrPostCallback(this.OnChangePasswordOperationCompleted);
            }
            this.InvokeAsync("ChangePassword", new object[] {
                        newPassword}, this.ChangePasswordOperationCompleted, userState);
        }
        
        private void OnChangePasswordOperationCompleted(object arg) {
            if ((this.ChangePasswordCompleted != null)) {
                System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
                this.ChangePasswordCompleted(this, new System.ComponentModel.AsyncCompletedEventArgs(invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
            }
        }
        
        /// <remarks/>
        public new void CancelAsync(object userState) {
            base.CancelAsync(userState);
        }
        
        private bool IsLocalFileSystemWebService(string url) {
            if (((url == null) 
                        || (url == string.Empty))) {
                return false;
            }
            System.Uri wsUri = new System.Uri(url);
            if ((((wsUri.Port >= 1024) 
                        && (wsUri.Port <= 5000)) 
                        && (string.Compare(wsUri.Host, "localHost", true) == 0))) {
                return true;
            }
            return false;
        }
    }
    
    /// <remarks/>
    [System.SerializableAttribute()]
    [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://oazabir.com/webservices/smartinstitute")]
    [System.Xml.Serialization.XmlRootAttribute(Namespace="http://oazabir.com/webservices/smartinstitute", IsNullable=false)]
    public partial class CredentialSoapHeader : System.Web.Services.Protocols.SoapHeader {
        
        private string usernameField;
        
        private string passwordHashField;
        
        private string versionNoField;
        
        private string securityKeyField;
        
        /// <remarks/>
        public string Username {
            get {
                return this.usernameField;
            }
            set {
                this.usernameField = value;
            }
        }
        
        /// <remarks/>
        public string PasswordHash {
            get {
                return this.passwordHashField;
            }
            set {
                this.passwordHashField = value;
            }
        }
        
        /// <remarks/>
        public string VersionNo {
            get {
                return this.versionNoField;
            }
            set {
                this.versionNoField = value;
            }
        }
        
        /// <remarks/>
        public string SecurityKey {
            get {
                return this.securityKeyField;
            }
            set {
                this.securityKeyField = value;
            }
        }
    }
    
    /// <remarks/>
    public delegate void AuthenticateUserCompletedEventHandler(object sender, AuthenticateUserCompletedEventArgs e);
    
    /// <remarks/>
    public partial class AuthenticateUserCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
        
        private object[] results;
        
        internal AuthenticateUserCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : 
                base(exception, cancelled, userState) {
            this.results = results;
        }
        
        /// <remarks/>
        public string Result {
            get {
                this.RaiseExceptionIfNecessary();
                return ((string)(this.results[0]));
            }
        }
    }
    
    /// <remarks/>
    public delegate void ChangePasswordCompletedEventHandler(object sender, System.ComponentModel.AsyncCompletedEventArgs e);
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Architect BT, UK (ex British Telecom)
United Kingdom United Kingdom

Comments and Discussions