tags:

views:

256

answers:

5

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  A: 

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

Daniel
foo is an _input_ to the service, specified at the client.
A: 

You probably need t osay that your parameters are required

[OperationContract] 
string HelloWorld([RequiredDataParameter] string foo,
                  [RequiredDataParameter] int bar);
leeeroy
Google only has two results for RequiredDataParameter, and one of them is this page, so probably not.
A: 

It's just try not to send any unneeded data.

Here is some more info:

http://stackoverflow.com/questions/1048112/why-does-a-web-service-datamembers-specified-attribute-need-to-be-set-for-int-an/1048132#1048132

eschneider
Thanks but the [DataMember(IsRequired = true)] technique does not appear to apply in this case, I'm not passing in a composite type, i'st happening on single non nullable value types, as illustrated above.
+1  A: 

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.

John Saunders
+1  A: 

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

Arthur Smirnov
Some sense at last. Thank you very much.