Question : WCF Client Proxy Wrapper Configuration Abstraction

Hi Experts,
I have a legacy ASP.NET3.5 Web Application that needs to call a SOAP1.2 Webservice for information. The web app is used by multiple customers and only a subset need the webservice.

So I want to design a solution where I could abstract the instantiation and configuration of the webservice client away from the web app. I don't want the web app to hold any webservice configuration information.

I decided to use WCF and in order to test, I created a simple test webservice console application in another solution. I then created a class Library project in the same solution as the WebApp to serve as a proxy client wrapper.  The class library contains the Client proxy code and exposes the data through a static method.  I referenced the service in the library and it generated the client proxy code from the services WSDL.

I am finding that the only way it will work is if the client proxy configuration code (the   section) is placed in the webapp's web.config file.

I have been searching for a way to avoid putting this code in the web.config. All of the posts I have seen only go so far as to say "put the config code in the web app". Perhaps I need to structure the projects differently  so that my proxy wrapper class library also produces a dll config file?

 I've attached my configuration section as well as the service code, but I think this is more of a project reference/structure issue.

Thanks in advance!
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:

    
      
        
          
          
          
            
            
          
        
      
    
    
      
        
          
        
      
    
   
 
    [ServiceContract(Namespace = "http//Redwood.NGT.BES")]
    public interface IBillingEnquiryStub
    {
 
        [OperationContract]
        string GetData(int value);
 
    }
 
 
    public class BESStubService : IBillingEnquiryStub
    {
        public string GetData(int value)
        {
            return string.Format("You entered: {0}", value);
        }
 
    }
    
    class Program
    {
        static void Main(string[] args)
        {
            Uri baseAddress = new Uri("http://localhost:1325/RedwoodNGTBES/Service");
 
            ServiceHost selfHost = new ServiceHost(typeof(BESStubService), baseAddress);
            try
            {
                // Step 3 of the hosting procedure: Add a service endpoint.
                selfHost.AddServiceEndpoint(
                    typeof(IBillingEnquiryStub),
                    new WSHttpBinding(),
                    "BESStubService");
 
                // Step 4 of the hosting procedure: Enable metadata exchange.
                ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
                smb.HttpGetEnabled = true;
                selfHost.Description.Behaviors.Add(smb);
 
                // Step 5 of the hosting procedure: Start (and then stop) the service.
                selfHost.Open();
                Console.WriteLine("The service is ready.");
                Console.WriteLine("Press  to terminate service.");
                Console.WriteLine();
                Console.ReadLine();
 
                // Close the ServiceHostBase to shutdown the service.
                selfHost.Close();
            }
            catch (CommunicationException ce)
            {
                Console.WriteLine("An exception occurred: {0}", ce.Message);
                selfHost.Abort();
            }
 
 
        }
    }

Answer : WCF Client Proxy Wrapper Configuration Abstraction

OK, after some review I see that this is really a configuration settings problem. The issue is that my wrapper dll is in a different AppDomain then my web application and as such the dll's configuration settings are not honored or produced when the library is compiled. The WebApps configuration settings are the only ones that are used. The best post I found is here http://stackoverflow.com/questions/594298?sort=newest#sort-top.

There are workarounds for this but it seems too much trouble managing two sets of config files. My solution will be to create a separate section in my web.config file to store client proxy configurations and manage those on a case by case basis. I believe I can actually fork them off into their own external config file for easier management. Hope this helps someone else!
Random Solutions  
 
programming4us programming4us