复制 WcfTestClient.exe 的功能

发布于 2024-11-07 10:35:07 字数 585 浏览 1 评论 0原文

我需要编写一个仅采用 Web 服务地址作为输入的应用程序(目前它可以只是一个简单的 http 地址,具有使用所有典型 WCF 介绍性 Visual Studio 示例生成的默认 Web 服务配置)。然后,我需要确定服务上的合同以及合同的所有方法(以及参数的类型)。

现在,我在网上找不到任何有关如何执行此操作的示例。然而,VS2008的WcfTestClient.exe正是这样做的。你输入一个地址,它似乎会连接到它几秒钟(所以我猜它不只是解析 wsdl 文件以获取信息,因为这甚至不会花费 1 秒),然后显示所有合约和合同上的方法为您列了一份整齐的清单。此外,WSDL 没有显示契约方法参数的确切类型。

我怎样才能自己以编程方式完成此操作?如果该测试应用程序只是调用 wsdl.exe 并在后台生成代理类,然后使用反射,我可能无法走这条路线,因为我无法在程序中调用命令行 .exe。如果是这种情况,我的问题就变成了,我怎样才能做 wsdl.exe 所做的事情......只有一个 Web 服务地址并获取这些代理类所需的所有信息。当然,在某个地方使用反射,这是我在这里的一等奖。

对于从哪里开始解决此问题的任何其他帮助将不胜感激。我对 WCF 和 Web 服务相当陌生,所以请注意。

谢谢你!

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 the 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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

何以畏孤独 2024-11-14 10:35:07

查看这篇文章 http://blogs.msdn.com/b/vipulmodi/archive/2006/11/16/dynamic-programming-with-wcf.aspx。它有您需要的内容,但代码会进行一些编译并动态加载新程序集(顺便说一句,我认为这就是 WcfTestClient 所做的),因此,如果由于某些安全问题而无法从程序中运行 .exe,那么这对你来说也可能是个问题。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文