开发者

Replicating what WcfTestClient.exe does

开发者 https://www.devze.com 2023-03-06 06:46 出处:网络
I need to write an app that only takes a webservice address as input (for now it can be just a simple http address with default web-service configuration as generated with all typical WCF introductory

I need to write an app that only takes a webservice address as input (for now it can be just a simple http address with default web-service configuration as generated with all typical WCF introductory Visual Studio examples). I then need to determine the contract on the service and all methods of the contract (with types of the parameters as well).

Now, I'm not finding any examples on the net on how to do this. However, the WcfTestClient.exe of VS2008 does precisely this. You type in an address, it seems to connect to it for a few seconds (so I'm guessing it doesn't just parse the wsdl file for information, as that won't take even 1 second) and then shows all contracts and methods on the contract for you in a neat list. Also, the WSDL doesn't show t开发者_如何转开发he exact types of the parameters to the contract methods.

How can I do this programmatically myself? If that test app simply calls the wsdl.exe and generates proxy classes in the background and then use reflection, I probably can't go this route, as I can't call command line .exes in my program. If this is the case though, my question becomes, how can I do what wsdl.exe does... only have a web service address and get all information needed for those proxy classes. And of course use Reflection somewhere, which is my first prize here.

Any other help on where to even start to resolve this issue will be greatly appreciated. I'm fairly new to WCF and web-services, so be warned.

Thank you!


Take a look at this post at http://blogs.msdn.com/b/vipulmodi/archive/2006/11/16/dynamic-programming-with-wcf.aspx. It has what you need, but the code does some compilation and loads the new assembly on the fly (which I think is what WcfTestClient does, BTW), so if you can't run .exe from your program because of some security issue, then it may be a problem for you as well.

0

精彩评论

暂无评论...
验证码 换一张
取 消