Communicate with multiple web service dynamically RRS feed

  • Question

  • User-1131354861 posted

    Hi All,

    I am looking for some advice on how I can do a piece of work I have. Basically I have multiple webservice that takes the same methods and parameters. And it is a pain to always have to get proxy classes, and change the code when a new provider is accepted and I am looking at ways to be able to add the webservice URL in my config and at runtime, be able to compile generate proxy classes and communicate with the remote machine dynamically.

    As an example: I have to send data to a method Called UpdateCustomers (int id, string name,string surname,DateTime DateofBirth) to a provider and if We decide to use provider A be able to change the webservice url in config to point to A, or when we decide to change to B etc...

    I am looking for hint and advice.


    Tuesday, July 26, 2016 8:48 AM

All replies

  • User-359936451 posted

    As long as you can build and maintain the list of providers A, B, etc. then it should be nothing more than a condition statement as to which proxy to connect to.

    Do you have the ability to select the provider when submitting the call to the method UpdateCustomer?

    If so, simply change the proxy request on that parameter...

    Dim returnVal as Type    ' Assume each service returns the same type/ if not Dim up your unique value for each.
    If providerA then
         returnVal = connectProxyProviderA
    ElseIf providerB then
         returnVal = connectProxyProviderB
    ElseIf providerC then
         ' returnVal = connectProxyProviderC
    Function connectProxyProviderA()
           Dim wsProvA as New webServiceName.EndpointA
    End Function
    Function connectProxyProviderB()
           Dim wsProvB as New webServiceName.EndpointB
    End Function

    Tuesday, July 26, 2016 5:29 PM