views:

101

answers:

1

So, our application needs support for dynamically calling web services which are unknown at compile time. The user should therefore be able to specify a URL to a WSDL, and specify some data bindings for the request and reply parameters.

When Googling for answers, it seems like the way to do this is by actually compiling a web service proxy class at runtime, loading it, and invoking the methods using reflection.

I think this seems like a rather clunky approach, given that I don't really need a strongly typed set of classes when I'm going to cast my data dynamically anyway. Dynamically compiling code for doing something that simple also just seems like The Wrong Way To Do It.

Restricting ourself to the SOAP protocol, is there any library for C# that implements this protocol for dynamic use? I can imagine that it would be possible to generate runtime key/value data structures from the WSDL, which could be used to specify the request messages, as well as reading the replies. The library should then be able to send well-formed SOAP messages to the server, and parse the replies, without the programmer having to generate the XML manually (at least not the headers and other plumbing).

I can't seem to find any library that actually does this. Is what I want to do really that esoteric, or have I just searched the wrong places?

Thanks,

Ulrik

A: 

I think that you will need to reflect the signature of the unknown web service in order to know how to call it.

But instead of compiling a webservice proxy you could use a javascript ajax call at runtime once you know what you need to call. You could use, for example, jquery.ajax() to make an XMLHttpRequest to the unknown web service (once you know what to call).

amelvin
Yeah, but the signature is specified in the WSDL.I want to make the call at server side, but even if I did want to make it at the client, an XMLHttpRequest still requires me to specify all of the SOAP plumbing myself.
Ulrik Rasmussen