在 Visual Studio 2010 中创建 WCF 服务引用时自定义消息协定

发布于 2024-11-13 23:04:12 字数 116 浏览 4 评论 0原文

在 Visual Studio 2010 中添加 WCF 服务引用时是否可以修改消息契约的生成方式?具体来说,我希望请求和响应对象具有属性而不是公共字段。

我无法控制 WCF 服务本身,只能控制客户端。

Is it possible to modify how message contracts are generated when adding a WCF service reference in Visual Studio 2010? Specifically I want the request and response objects to have properties instead of public fields.

I have no control over the WCF service itself, just the client.

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

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

发布评论

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

评论(2

月朦胧 2024-11-20 23:04:12

我认为您无法控制生成的代理,但您可以在构建它们后对其进行修改。为什么要更改代理?

I don't think you can control the proxies that get generated, but you can modify them once they are built. Why do you want to change the proxy?

[旋木] 2024-11-20 23:04:12

您无法控制生成的代理中的代码。如果需要,您可以使用 MetadataExchangeClient / ServiceContractGenerator 类自行生成代理。他们将为您提供一个 CodeDom 对象,其中包含您可以修改的代码(即将字段更改为属性)。 MSDN 论坛帖子中有一个使用 MEC/SCG 类的示例,网址为 http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/14100bbb-9a73-4bcc-b513-088bb2e5ec65

You can't control the code in the generated proxy. If you want, you can do the proxy generation yourself, using the MetadataExchangeClient / ServiceContractGenerator classes. They'll give you a CodeDom object containing the code which you can modify (i.e., change fields into properties). There's an example of using the MEC/SCG classes in the MSDN forum post at http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/14100bbb-9a73-4bcc-b513-088bb2e5ec65.

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