Click here to Skip to main content
15,891,204 members
Articles / Programming Languages / C#

Runtime Generated WCF Service Exposing .NET or COM Types

Rate me:
Please Sign up or sign in to vote.
4.69/5 (38 votes)
24 Apr 2008CPOL8 min read 79.9K   1.1K   51  
A WCF service wrapper is generated at runtime around a .NET or COM type to expose its interface.
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.1433
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace ConsoleClient.Class1 {
    
    
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
    [System.ServiceModel.ServiceContractAttribute(ConfigurationName="Class1.IClass1")]
    public interface IClass1 {
        
        [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IClass1/Add", ReplyAction="http://tempuri.org/IClass1/AddResponse")]
        int Add(int a);
        
        [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IClass1/Subtract", ReplyAction="http://tempuri.org/IClass1/SubtractResponse")]
        int Subtract(int a);
        
        [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IClass1/set_Count", ReplyAction="http://tempuri.org/IClass1/set_CountResponse")]
        void set_Count(int value);
        
        [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IClass1/get_Count", ReplyAction="http://tempuri.org/IClass1/get_CountResponse")]
        int get_Count();
        
        [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IClass1/Concat", ReplyAction="http://tempuri.org/IClass1/ConcatResponse")]
        string Concat(string ins);
    }
    
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
    public interface IClass1Channel : ConsoleClient.Class1.IClass1, System.ServiceModel.IClientChannel {
    }
    
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
    public partial class Class1Client : System.ServiceModel.ClientBase<ConsoleClient.Class1.IClass1>, ConsoleClient.Class1.IClass1 {
        
        public Class1Client() {
        }
        
        public Class1Client(string endpointConfigurationName) : 
                base(endpointConfigurationName) {
        }
        
        public Class1Client(string endpointConfigurationName, string remoteAddress) : 
                base(endpointConfigurationName, remoteAddress) {
        }
        
        public Class1Client(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : 
                base(endpointConfigurationName, remoteAddress) {
        }
        
        public Class1Client(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : 
                base(binding, remoteAddress) {
        }
        
        public int Add(int a) {
            return base.Channel.Add(a);
        }
        
        public int Subtract(int a) {
            return base.Channel.Subtract(a);
        }
        
        public void set_Count(int value) {
            base.Channel.set_Count(value);
        }
        
        public int get_Count() {
            return base.Channel.get_Count();
        }
        
        public string Concat(string ins) {
            return base.Channel.Concat(ins);
        }
    }
}

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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
Israel Israel


  • Nov 2010: Code Project Contests - Windows Azure Apps - Winner
  • Feb 2011: Code Project Contests - Windows Azure Apps - Grand Prize Winner



Comments and Discussions