I have a WCF service, which in turn has a service reference for some other SOAP endpoint. This endpoint has an identical copy at a different address with the same metadata but with different data. When a request arrives at my service, it indicates which of the two identical endpoints that I consume, it wants to receive data. So, I have something like this:
using (var client = new ServiceClient()) { client.Endpoint.Address = new System.ServiceModel.EndpointAddress(url);
This sometimes does not work when I have two requests that are very close to each other with different URLs. The second request ends with an exit to the same endpoint as the first. I understand that as soon as the channel is open, I cannot change the endpoint, but I thought that the client would be used only once, and then it would be deleted. Is there any kind of optimization when the same proxy is reused for multiple requests? What is a good approach to such problems?
EDIT: More details:
The snippet is part of the method (let it call foo ()) that was open to users of my RESTful service. This is not static. The endpoint URL is a local string that is provided as part of the URI.
[OperationContract] [WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json, UriTemplate = "getStuff?url={url}")] string foo(string url); public string foo(string url) { using (var client = new ServiceClient()) { client.Endpoint.Address = new System.ServiceModel.EndpointAddress(url);
I have not configured anything explicitly for the concurrency control. I understand the theory underlying it, but I have no technical experience, so any manual work will be greatly appreciated.
Also! There was a semi-probable reason to change the endpoint address, rather than specifying it in the proxy constructor. However, for testing purposes, I just tried to specify in the constructor and it seems to work fine (thanks to JMeter!). With a little work, I could rebuild the real code to work this way, but I would still be very grateful for the explanation. Training is important.
source share