Chaging dynamically Reference.cs of WCF Service

948 views Asked by At

I am in the process of developing a WCF Service(WCFManager) which would send out request to other services and get response back. For this I developed a WCF service.

Trying to accomplish the following (Assuming that my service name is WCFManager)

What I did so far

  1. Added a service reference of Service X to WCFManager which created a reference.cs and a WCF Client.
  2. Using the WCF Client generated by adding service reference and sending the request to Service X by using the following code

    WCFManagerClient client = new WCFManagerClient();
    Response response = client.GetResponse(request);
    

What am I trying to accomplish

  1. I want to add few config settings in a App.Config file of Service X, Service Y, Service Z which I did.
  2. Reuse the same WCFManagerClient to send the request to Service Y or Service Z by reading the endpoint information from the config file. My assumption is that when I use the WCFManagerClient to send the request it uses the reference.cs created in the service reference of the WCFManager service.If my assumption is true can I change the reference.cs on the fly to include the Service Y binding information when I send the request to Service Y and same with the Service Z. This way I don't have to create a proxy for each Service.
  3. Is it possible to reuse the same reference.cs file generated but include the binding information on the fly from config file. 3.I have no control over the Service Y or Service Z but all I know is services Endpoint information and the method names and the schema of each service would be the same.

I am not sure if this is possible in WCF if some one has gone through such design with WCF but any suggestions about my approach is apreciated.

0

There are 0 answers