Question

Has anybody got any kind of experience with dynamic programming using WCF. By dynamic programming I mean runtime consumption of WSDL's. I have found one blog entry/tool: http://blogs.msdn.com/vipulmodi/archive/2006/11/16/dynamic-programming-with-wcf.aspx

Has anybody here found good tools for this?

Was it helpful?

Solution

This is one of the weirder aspects of WCF. You can dynamically create a channelfactory, but only with a known type.

I came up with a solution that is not perfect, but does work:

Create an interface, "IFoo" which contains a single method, say Execute(). In your ESB, dynamically create a ChannelFactory<IFoo> for the endpoint that you want to connect to. Set the connection properties (URI, etc.).

Now, you can attach services dynamically to your ESB, provided that they always implement the "IFoo" interface.

OTHER TIPS

I have done this a long time ago with SOAP web services. There was a tool on GotDotNet which I think has become Web Services Studio Express, that had code which inspected/parsed a WSDL file and allowed you to call it.

I think the assumption is that the WSDL is known at the time of client creation, and you don't need to be hooked up at runtime. If you inspect the WSDL at runtime you still need to have some sort of logic to decide how to generate the proxy. Why would can you not consume the WSDL before runtime? Web Services are supposed to be fairly static with an interface that doesn't change once published.

You can use .NET CodeDom to generate code to execute and use the web service described by the WSDL. The WSDL can be parsed using the standard .NET XML classes.

I am actually considering making a small ESB, where a user can add a webservice to route to at run time. So I can not add WSDLs statically

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top