Dynamically invoke web service at runtime
Posted
by Ulrik Rasmussen
on Stack Overflow
See other posts from Stack Overflow
or by Ulrik Rasmussen
Published on 2010-04-30T08:52:40Z
Indexed on
2010/04/30
8:57 UTC
Read the original article
Hit count: 254
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
© Stack Overflow or respective owner