Click here to Skip to main content
15,881,882 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.StudentService {
    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="StudentServiceSoap", Namespace="http://oazabir.com/webservices/smartinstitute")]
    [System.Xml.Serialization.XmlIncludeAttribute(typeof(AccountBase))]
    [System.Xml.Serialization.XmlIncludeAttribute(typeof(AssessmentBase))]
    [System.Xml.Serialization.XmlIncludeAttribute(typeof(CourseTakenByStudentBase))]
    [System.Xml.Serialization.XmlIncludeAttribute(typeof(StudentBase))]
    public partial class StudentService : System.Web.Services.Protocols.SoapHttpClientProtocol {
        
        private CredentialSoapHeader credentialSoapHeaderValueField;
        
        private System.Threading.SendOrPostCallback GetStudentDetailsOperationCompleted;
        
        private System.Threading.SendOrPostCallback GetAllStudentsOperationCompleted;
        
        private System.Threading.SendOrPostCallback SyncStudentOperationCompleted;
        
        private bool useDefaultCredentialsSetExplicitly;
        
        /// <remarks/>
        public StudentService() {
            this.Url = SmartInstitute.Automation.Properties.Settings.Default.SmartInstitute_Automation_SmartInstituteServices_StudentService_StudentService;
            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 GetStudentDetailsCompletedEventHandler GetStudentDetailsCompleted;
        
        /// <remarks/>
        public event GetAllStudentsCompletedEventHandler GetAllStudentsCompleted;
        
        /// <remarks/>
        public event SyncStudentCompletedEventHandler SyncStudentCompleted;
        
        /// <remarks/>
        [System.Web.Services.Protocols.SoapHeaderAttribute("CredentialSoapHeaderValue")]
        [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://oazabir.com/webservices/smartinstitute/GetStudentDetails", 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 Student GetStudentDetails(int userID) {
            object[] results = this.Invoke("GetStudentDetails", new object[] {
                        userID});
            return ((Student)(results[0]));
        }
        
        /// <remarks/>
        public void GetStudentDetailsAsync(int userID) {
            this.GetStudentDetailsAsync(userID, null);
        }
        
        /// <remarks/>
        public void GetStudentDetailsAsync(int userID, object userState) {
            if ((this.GetStudentDetailsOperationCompleted == null)) {
                this.GetStudentDetailsOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetStudentDetailsOperationCompleted);
            }
            this.InvokeAsync("GetStudentDetails", new object[] {
                        userID}, this.GetStudentDetailsOperationCompleted, userState);
        }
        
        private void OnGetStudentDetailsOperationCompleted(object arg) {
            if ((this.GetStudentDetailsCompleted != null)) {
                System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
                this.GetStudentDetailsCompleted(this, new GetStudentDetailsCompletedEventArgs(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/GetAllStudents", 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 Student[] GetAllStudents() {
            object[] results = this.Invoke("GetAllStudents", new object[0]);
            return ((Student[])(results[0]));
        }
        
        /// <remarks/>
        public void GetAllStudentsAsync() {
            this.GetAllStudentsAsync(null);
        }
        
        /// <remarks/>
        public void GetAllStudentsAsync(object userState) {
            if ((this.GetAllStudentsOperationCompleted == null)) {
                this.GetAllStudentsOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetAllStudentsOperationCompleted);
            }
            this.InvokeAsync("GetAllStudents", new object[0], this.GetAllStudentsOperationCompleted, userState);
        }
        
        private void OnGetAllStudentsOperationCompleted(object arg) {
            if ((this.GetAllStudentsCompleted != null)) {
                System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
                this.GetAllStudentsCompleted(this, new GetAllStudentsCompletedEventArgs(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/SyncStudent", 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 bool SyncStudent(Student student) {
            object[] results = this.Invoke("SyncStudent", new object[] {
                        student});
            return ((bool)(results[0]));
        }
        
        /// <remarks/>
        public void SyncStudentAsync(Student student) {
            this.SyncStudentAsync(student, null);
        }
        
        /// <remarks/>
        public void SyncStudentAsync(Student student, object userState) {
            if ((this.SyncStudentOperationCompleted == null)) {
                this.SyncStudentOperationCompleted = new System.Threading.SendOrPostCallback(this.OnSyncStudentOperationCompleted);
            }
            this.InvokeAsync("SyncStudent", new object[] {
                        student}, this.SyncStudentOperationCompleted, userState);
        }
        
        private void OnSyncStudentOperationCompleted(object arg) {
            if ((this.SyncStudentCompleted != null)) {
                System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
                this.SyncStudentCompleted(this, new SyncStudentCompletedEventArgs(invokeArgs.Results, 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 GetStudentDetailsCompletedEventHandler(object sender, GetStudentDetailsCompletedEventArgs e);
    
    /// <remarks/>
    public partial class GetStudentDetailsCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
        
        private object[] results;
        
        internal GetStudentDetailsCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : 
                base(exception, cancelled, userState) {
            this.results = results;
        }
        
        /// <remarks/>
        public Student Result {
            get {
                this.RaiseExceptionIfNecessary();
                return ((Student)(this.results[0]));
            }
        }
    }
    
    /// <remarks/>
    public delegate void GetAllStudentsCompletedEventHandler(object sender, GetAllStudentsCompletedEventArgs e);
    
    /// <remarks/>
    public partial class GetAllStudentsCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
        
        private object[] results;
        
        internal GetAllStudentsCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : 
                base(exception, cancelled, userState) {
            this.results = results;
        }
        
        /// <remarks/>
        public Student[] Result {
            get {
                this.RaiseExceptionIfNecessary();
                return ((Student[])(this.results[0]));
            }
        }
    }
    
    /// <remarks/>
    public delegate void SyncStudentCompletedEventHandler(object sender, SyncStudentCompletedEventArgs e);
    
    /// <remarks/>
    public partial class SyncStudentCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
        
        private object[] results;
        
        internal SyncStudentCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : 
                base(exception, cancelled, userState) {
            this.results = results;
        }
        
        /// <remarks/>
        public bool Result {
            get {
                this.RaiseExceptionIfNecessary();
                return ((bool)(this.results[0]));
            }
        }
    }
}

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