1

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...

The webservices are .asmx or .svc

I am looking for hint and advice.

Regards

Jack M
  • 2,564
  • 4
  • 28
  • 49

1 Answers1

1

Sounds like a job for WCF Routing.

Depending on how you want to route your calls, you can define message filters which you can use to evaluate if incoming calls fulfil a set of criteria, for example, that a certain value in the soap payload is set to a specific value:

<filters>
    <filter name="myXPathFilter1" 
            filterType="XPath" 
            filterData="//valueIWantToFilterOn = somevalue"/>
</filters>

You can then register the filter to map to a specific endpoint:

<filterTables>
    <table name="myRoutingTable">
        <filters>
           <add filterName="myXPathFilter1" endpointName="UpdateCustomers1" />
           <add filterName="myXPathFilter2" endpointName="UpdateCustomers2" />
           ...
        </filters>
    </table>
</filterTables>
tom redfern
  • 30,562
  • 14
  • 91
  • 126