为什么WCF有时会添加"Field"字段?到生成的代理类型的结尾? [英] Why does WCF sometimes add "Field" to end of generated proxy types?

查看:93
本文介绍了为什么WCF有时会添加"Field"字段?到生成的代理类型的结尾?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上,我有一个带有成员X和Y的服务器端类型"Foo".每当我使用Visual Studio的添加服务器引用"时,我都会看到WSDL和生成的代理都将单词"Field"附加到所有成员并更改首字母的大小写. IE,"X"和"Y"被重命名为"xField"和"yField".知道为什么会这样吗?我无法弄清楚模式.

Basically, I have a server-side type "Foo" with members X and Y. Whenever I use Visual Studio's "Add Server Reference" then I see the WSDL and the generated proxy both append the word "Field" to all the members and change the casing of the first letter. IE, "X" and "Y" are renamed "xField" and "yField". Any idea why this is happening? I can't figure out the pattern.

详细信息-我有一个传统的ASMX Web服务,它公开了"Foo"类型.我创建了一个新的WCF服务,该服务是该旧Web服务的包装器-新服务仅包装这些方法并可能更新了几个字段的值,但它公开了完全相同的方法并返回了完全相同的类型.我已经尝试过多次重新创建Referenes,并且每次都始终重命名我的字段:变量"STUFF"在wsdl和代理中公开为"sTUFFField".变量"X"显示为"xField"等.

Details -- I have a legacy ASMX web service which exposes a "Foo" type. I created a new WCF service that's a wrapper around that old web service -- the new service just wraps those methods and maybe updates the values of a few fields, but it exposes the exact same methods and returns the exact same types. I've tried re-creating the referenes several times, and every time, it always renames my fields: the varible "STUFF" is exposed in the wsdl and proxy as "sTUFFField". Variable "X" is exposed as "xField", etc.

有趣的是,我无法弄清楚模式-我尝试创建一个新的ASMX Web服务作为测试并将其包装-那时,变量未重命名.因此我无法弄清楚WCF重命名变量的原因/方式.

Funny thing is I can't figure out the pattern -- I tried creating a new ASMX web service as a test and wrapping that -- variables are not renamed then. So I can't figure out the pattern of why/when WCF renames variables.

有人知道吗?

推荐答案

我遇到了同样的问题,而sergiosp的回答使我朝着正确的方向前进.只是添加一些其他信息以希望对其他人有所帮助.

I had the same issue, and sergiosp's answer got me headed in the right direction. Just adding some additional info to hopefully help someone else.

在接口中添加[System.ServiceModel.XmlSerializerFormatAttribute()],然后重新生成客户端代码,这对我来说解决了这个问题.

Adding [System.ServiceModel.XmlSerializerFormatAttribute()] to the interface, and re-generating the client code resolved the problem for me.

public interface IMyService
{
    [System.ServiceModel.XmlSerializerFormatAttribute()]
    [System.ServiceModel.OperationContract]
    recordResponse GetRecord(recordRequest request);

}

这篇关于为什么WCF有时会添加"Field"字段?到生成的代理类型的结尾?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆