none
CSharp WCF Web Service with Constructor using Visual Studio 2008 SP1 RRS feed

  • Question

  • Dear All,

    I am looking for WCF Web Service with Constructor using Visual Studio 2008 SP1.

    So far, I could manage to find the code snippets below

    // IService.cs
    namespace WCF
    {
        [ServiceContract]
        public interface IService
        {
    
            [OperationContract]
            ReadDataResponse ReadData(ReadDataRequest request);
        
        }
    }
    // ReadDataRequest.cs
    
    namespace WCF
    {
        public partial class ReadDataRequest : object, System.ComponentModel.INotifyPropertyChanged
        {
            
            private string dataIdField;
            
            /// <remarks/>
            public string dataId
            {
                get
                {
                    return this.dataIdField;
                }
                set
                {
                    this.dataIdField = value;
                    this.RaisePropertyChanged("dataId");
                }
            }
            
            public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
            
            protected void RaisePropertyChanged(string propertyName)
            {
                System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
                if ((propertyChanged != null))
                {
                    propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
                }
            }
        }
    }
    //ReadDataRequest1.cs
    
    namespace WCF
    {
        [DataContract]
        public partial class ReadDataRequest1
        {
    
            [System.ServiceModel.MessageBodyMemberAttribute]
            public ReadDataRequest ReadDataRequest;
    
    		// How to go inside to read a = 1 here ?
            public ReadDataRequest1()
            {
                int a = 1;
            }
    
            
            public ReadDataRequest1(ReadDataRequest ReadDataRequest)
            {
                this.ReadDataRequest = ReadDataRequest;
            }
    
            string data_ID;
      
            [DataMember]
            public string data_ID
            {
                get { return data_ID; }
                set { data_ID = value; }
    			// How to read data input from WCFConsole Test in here
            }
                  
        }
    }
    
    //ReadDataResponse.cs
    namespace WCF
    {
        
        public partial class ReadDataResponse : object, System.ComponentModel.INotifyPropertyChanged
        {
            
            private ReturnCodeType returnCodeField;
            
            private DataType dataField;
            
            /// <remarks/>
            public ReturnCodeType ReturnCode
            {
                get
                {
                    return this.returnCodeField;
                }
                set
                {
                    this.returnCodeField = value;
                    this.RaisePropertyChanged("ReturnCode");
                }
            }
            
            /// <remarks/>
            public DataType Data
            {
                get
                {
                    return this.dataField;
                }
                set
                {
                    this.dataField = value;
                    this.RaisePropertyChanged("Data");
                }
            }
            
            public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
            
            protected void RaisePropertyChanged(string propertyName)
            {
                System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
                if ((propertyChanged != null))
                {
                    propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
                }
            }
        }
    }
    
    // ReadDataResponse1.cs
    namespace WCF
    {
        [DataContract]
        public partial class ReadDataResponse1
        {
    
            public ReadDataResponse ReadDataResponse;
    
            public ReadDataResponse1()
            {
            }
    
            public ReadDataResponse1(ReadDataResponse ReadDataResponse)
            {
                this.ReadDataResponse = ReadDataResponse;
            }
    
            ////////////////////////////////////////////////////////////////
            // Dummy Data Response from Server
            [DataMember]
            public string errDescription = "Read Data";          // Return Error From Exception
            [DataMember]
            public string retCode;                                      // Return Code reply form Server that is read by another dll created by me
            
        }
    }
    
    //WCFService.cs
    namespace WCF
    {
       
        public class WCFService : IService
        {
        
            [OperationBehavior]
            public ReadDataResponse1 ReadData(ReadDataRequest1 request)
            {
                ReadDataResponse1 readData = new ReadDataResponse1();
    
                return readData;
            }
        }
    }
    

    I hope someone will advise me to get it done.

    Thanks and best regards




    Wednesday, March 13, 2013 10:52 AM

Answers