72176

SOAP web service: many servers, one interface

I have a scenario in which I'm going to need an arbitrary number of servers to provide the same SOAP web service. I would like to generate one set of proxy classes and be able to supply them with a location to point them at the different servers at runtime. Unfortunately, it looks as though the wsdl:port node (child of wsdl:service) requires the address of a specific server to be hardcoded. It appears that due to this the URL will be baked into my proxy classes. I know that I could potentially modify this by hand-editing the generated proxy classes, or modifying the code generation, but I'd really prefer not to resort to that. I feel like there's got to be a better way to solve this problem. I just want to decouple the interface definition from the location that the service will be residing at. I'm using VS2008 and C#.NET if that's of any help though best would be a language-agnostic (SOAP or WSDL specific) general solution to this problem.

Answer1:

Why don't you load balance the web servers and then create a DNS entry for the load balanced IP address....essentially creating a web farm. This will allow you to reference the hostname rather than the static IP addresses and if you ever need to change the IP address of the load balancer or the web servers it is a one time change. Plus you then have redundancy and performance control.

Answer2:

If you're using a WebReference (pre-WCF) to get to the web service, you can simply set the Url property on the web service proxy class after you create it.

For WCF, you can provide a different endpoint address to the proxy class constructor, rather than using the default (among other possible solutions).

Answer3:

No, in .NET you can change the URL at runtime.

Service svc = new Service (); svc.url = "Value read from config. file or some such" output = svc.method (input);

Answer4:

When you add a web reference to your project, it places the address of the web service into the .config file of your application / web application. You can then simply change this setting in the config file to point to a different web service location, assuming of course that the services are identical.

Answer5:

The easiest solution would be to use a software load balancer such as HAProxy. At more cost, you could use a hardware solution such as Big-IP.

Answer6:

Here's a hint on how to decide the URL of WSDL. I´m just changing the port but it´s of course possible to make it more advanced.

public class PortChangeReflector : SoapExtensionReflector { public override void ReflectDescription() { ServiceDescription description = ReflectionContext.ServiceDescription; foreach (Service service in description.Services) { foreach (Port port in service.Ports) { foreach (ServiceDescriptionFormatExtension extension in port.Extensions) { SoapAddressBinding binding = extension as SoapAddressBinding; if (binding != null && !binding.Location.Contains("8092")) { binding.Location = binding.Location.Replace("92", "8092"); } } } } } }

Put that in your Add_Code and add the following reference to your web.config.

<webServices> <soapExtensionReflectorTypes> <add type="Dev.PortChangeReflector,App_Code"/> </soapExtensionReflectorTypes> </webServices>

I hope you can get new ideas of this.

Answer7:

Client proxies have URL property you can set at runtime. To make it simpler, wsdl.exe utility has /appsettingurlkey key. When you generate a client proxy, it's constructor will check the key in appSettings and set the service URL accordingly. I believe WCF has this feature as well.

However, I would agree with @Matt and suggest you consider load balancing as the best solution in the long run.

Answer8:

<ol> <li>Is this for scaling (each server provides the same data) or </li> <li>for same API different data on each server?</li> </ol>

For 2, then you can do as above, just change the service URL in code.

For 1, you could use round-robin DNS (e.g. you see multiple servers with at the command line type nslookup www.google.com).

Recommend

  • Understanding the quality of the KMeans algorithm
  • IP address of Azure API App and how to restrict IPs
  • Trapping Object required: '[object]' with MSXML2.ServerXMLHTTP.6.0
  • HBase region over region servers load not balanced
  • Accessing types defined inside package from java
  • How to join two tables and map the result to a case class in slick
  • How many wiki instances to install?
  • How to get elements with a unique number from a json array in PostgreSQL?
  • How to manage state in JAX-RS?
  • Using cross_val_predict against test data set
  • Objective-C : getting error on console while trying to display app on ipad device?
  • Read stdin in chunks in Bash pipe
  • Weighted round robin dns between 2 Cloudfront distributions
  • Checking whether the server is on/off
  • Google OAuth2 for an web application hosted behind NAT (intranet server without public IP)
  • DNS Lookup failed - Error with all browsers [closed]
  • How to resolve docker host names (/etc/hosts) in containers
  • Should I be afraid to use UDP to make a client/server broadcast talk?
  • Quick Question About Get and Set
  • Find VMID for running instance
  • Unix Network Programming Clarification
  • Django model for a Postgres view
  • using System.Speech.Synthesis with Windows10 universal app (XAML-C#)
  • Clarification on min distance on LocationManager.requestLocationUpdates method, min Distance paramet
  • GAE: Way to get reference to an HttpSession from its ID?
  • Spring boot 2.0.0.M4 required a bean named 'entityManagerFactory' that could not be found
  • What is the purpose of TaskExecutor in spring?
  • Insert new calendar with SyncAdapter- Calendar API Android
  • Cannot resolve symbol 'MyApi'
  • Initializer list vs. initialization method
  • Control modification in presentation layer
  • Sails.js/waterline: Executing waterline queries in toJSON function of a model?
  • Fetching methods from BroadcastReceiver to update UI
  • Align navbar back button on right side
  • What do the 'size' numbers mean in the windbg !heap output?
  • Comma separated Values
  • Error creating VM instance in Google Compute Engine
  • Hits per day in Google Big Query
  • how does django model after text[] in postgresql [duplicate]