Evaluate Weigh the pros and cons of technologies, products and projects you are considering.

Dynamically binding to a service

Can we dynamically change the WSDL during runtime? We would like to create one Web service for multiple WSDLs.
There are a number of different ways that I can interpret your question, but I'll assume that you're asking whether a Web service client can switch between multiple Web services at runtime by dynamically binding to the appropriate WSDL file.

The answer is yes. SOAP and WSDL give you the ability to dynamically bind to a service. The means by which you do so may be limited by the tool you're using, though. In order to dynamically bind to a service, you cannot use a compiled stub. Instead you must use a dynamic proxy or a dynamic invocation interface (DII). If all the services expose the same interface (as defined by the ), then you can use a dynamic proxy to switch between web services. If the services expose different interfaces, then you must use a DII.

The JAX-RPC API requires support for both dynamic proxy and DII. A dynamic proxy works very much like a compiled stub. You must generate an interface at development time, and then at runtime you generate a dynamic proxy and cast it to the interface. At that point you can invoke operations on the interface just as you would with a compiled stub. A DII is much more challenging, and many product implementations don't support complex types when using the DII. Most scripting tools do not support dynamic proxy or DII, so when using these environments, you'll need to use the low-level programming interface that allows you to work at the raw SOAP level. .NET does not natively support dynamic proxies, but a number of add-in products, such as Spring.NET and DynamicProxy.NET, add support for dynamic proxies in .NET.

As an alternative, you can simply compile multiple stubs for all the services that you want to access. Of course, this approach doesn't permit dynamic discovery.

Dig Deeper on Topics Archive

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.