Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are these extra parameters in my ASMX Proxy Methods?

Tags:

c#

.net

wcf

asmx

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?

like image 653
stovroz Avatar asked Feb 17 '10 22:02

stovroz


3 Answers

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

like image 158
Arthur Smirnov Avatar answered Nov 15 '22 16:11

Arthur Smirnov


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.

like image 21
John Saunders Avatar answered Nov 15 '22 16:11

John Saunders


.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.

like image 41
Daniel Avatar answered Nov 15 '22 18:11

Daniel