Sunday, 15 July 2012

c# - How to use one binding for multiple web services of the same type? -


In WCF web service deployment I need a web service to connect to multiple services of the same type. I

Those services Has been dynamically added to the deployment, and their number should be flexible, clearly, "making compulsive" in general is not a solution in this matter, because I will need to make binding in every service that I will end Can Not.

What will be the recommended approach for this? First of all, I was thinking of binding for one of the multiple services (before compiling time), new services added had to be negotiated at just the end point and I would change the names of the services before sending them.

Is there any proper way to deal with the same type of services without repeating the binding?

I feel very bad and bad, if I want to send those services in parallel. WCF has not been customized with more complex situations and if I have not explained this issue well then it can help me to re-write this question and find new search terms for my issue.

I recommend configuring a client program, that is an example. The endpoint url you can store in a saparate file can be modified to durin deployment of the file

  var myBinding = new BasicHttpBinding (); Var urlList = GetUrlsFromCustomConfigFile (); Var factoriesofSmap = new list & lt; ChannelFactory & lt; IMyService & gt; & Gt; (); Foreach (ur URL in urlList) {var myEndpoint = new endpoint (url); Var myChannelFactory = New Channel Factor & lt; IMyService & gt; (MyBinding, myEndpoint); FactoriesOfTheSameType.Add (myChannelFactory); }   

Now you can create clients using 'mychannelfactory' and can call them in parallel or whatever else they need with it.

No comments:

Post a Comment