WCF - Dynamically invoke multiple web service endpoints that implement the same interface

I have several different applications that implement the same contract. In my main application, I would like to have one proxy. Then dynamically, given the Uri for a particular application, I would create a web service request and call. How can I do that? Thank!

+3
source share
2 answers

Follow these steps:

  • create your client proxy based on one service
  • this will create C # / VB.NET classes for you as well app.config(or web.configif your client is a web application)

  • when calling the default service endpoint, you can do something like:

    YourServiceClient client = new YourServiceClient();
    client.CallSomeMethod();
    

    , .

  • , :

    YourServiceClient client = 
       new YourServiceClient("default", "http://server/YourOtherService.svc");
    client.CallSomeMethod();
    

    , : ( , ) URL ( , ).

, , .. , , , .

+7

, uri

ReconcileSvc.ReconcileClient client = new ReconcileClient();
client.Endpoint.Address = new System.ServiceModel.EndpointAddress(uri);

, .

+3

Source: https://habr.com/ru/post/1784174/


All Articles