What are these extra parameters in my ASMX Proxy Methods?

牧云@^-^@ 提交于 2019-12-18 05:54:27

问题


If I add a web reference from a .NET 1.1 client to a WCF service, the proxy methods generated at the client contain an extra parameter ending with the suffix 'Specified' for each service method parameter, e.g.

[OperationContract]
string HelloWorld(string foo, int bar);

results in:

Service1.HelloWorld(string foo, bool fooSpecified, int bar, bool barSpecified);

My service parameters aren't optional so what are these extra parameters at the client, and how can I get rid of them?


回答1:


This is due to a difference in the serialization mechanisms used in WCF and ASMX Web Services. To avoid extra params you must specify XmlSerializerFormat attribute on ServiceContract.

for add read this: http://msmvps.com/blogs/windsor/archive/2008/05/17/calling-wcf-services-from-net-1-1.aspx




回答2:


The issue is with parameters of a value type when they are permitted to be absent. .NET 1.1 has no way to specify this without the *specified parameters. They need to be set to true to indicate that the corresponding parameter is being sent.




回答3:


.NET 1.1 Web services don't have a concept of null so WCF is generating these extra properties for you. fooSpecified = false means foo is really null.




回答4:


You probably need t osay that your parameters are required

[OperationContract] 
string HelloWorld([RequiredDataParameter] string foo,
                  [RequiredDataParameter] int bar);


来源:https://stackoverflow.com/questions/2284760/what-are-these-extra-parameters-in-my-asmx-proxy-methods

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!