生成 WebMethod 不使用的代理类

发布于 2024-08-18 12:48:41 字数 456 浏览 1 评论 0原文

我对这个问题有相反的看法: wsdl:为 WebMethod 生成代理,但不是其他依赖类

如何自动生成对客户端有用但既不是 DataContracts 也不是 ServiceContracts 的其他类(实用程序类)?换句话说,想要提取特定的类而不是包含整个 DLL。

编辑:是的任意类。我认为我们最终会将它们提取到 DLL 中,而不是它们当前所属的部分。只是想知道是否有一种方法使用反射或工具将特定的类从源 DLL 复制到目标 DLL。 “代理”可能是错误的词,因为这些方法不会调用 WCF。相反,它们将是普通的类,只不过它们是从源 DLL 复制的。 (原因是,不想共享所有(可反编译的)DLL。)

I have sortof the opposite of this question:
wsdl : Generate Proxy for the WebMethods but not the other dependent classes

How can one auto-generate other classes (utility classes) that are useful on the client side but are neither DataContracts nor ServiceContracts? In other words, wanting to extract specific classes instead of including entire DLL's.

Edit: Yes arbitrary classes. I think we will end up extracting those to a DLL other then the ones they're currently part of. Just wondering if there is a way using reflection or tool to copy out only specific classes from a source DLL to a destination DLL. "Proxy" is probably the wrong word because the methods wouldn't call WCF. Instead they would be normal classes, other than that they were copied from a source DLL. (The reason is, not wanting to share all of (decompilable) DLL's.)

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

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

发布评论

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

评论(2

烟火散人牵绊 2024-08-25 12:48:41

如果源 dll 是您控制的东西,那么复制类确实会导致以后出现问题。更好的方法是将共享类提取到客户端和服务器项目都可以引用的“共享”或“互操作”或“通用”DLL。

这样做还有助于将数据与逻辑分离,因为共享/互操作/公共项目不应引用其他任何内容,并且是非常简单的数据容器。

If the source dll is something you control, then copying classes is really going to lead to problems down the road. The better approach would be to extract the shared classes to a "Shared" or "Interop" or "Common" dll that the client and server projects can both reference.

Doing this also helps separate data from logic since the shared/interop/common project shouldn't reference anything else and is very simply data containers.

勿忘初心 2024-08-25 12:48:41

您无法通过 WSDL 指定方法实现。为了完成您想要做的事情,您需要创建一个构建脚本/宏来创建和编译一个具有代理和您的 util 方法的客户端库。

华泰

You can't specify method implementaion thru WSDL. In order to accomplish what you are trying to do you would need to create a build script / marcro that creates and compiles a client library which has the proxy and your util methods.

HTH

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