Why is powershell adding additional parameters to Web Service Method Signatures

Question:

I’m trying to use Powershell to ping a couple of WCF Webservices from the command line. e.g.

I have an WCF Operation

And I can call that with Powershell using.

This works fine as long as the input params and return types are strings. However if I introduce integers, the generated method signatures & return types have additional paramSpecified properties generated.

Consider the following Method with a Data Contract return type.

Problem 1

The signature of the method is wrong & has an extra parameter bool howManySpecified.

Problem 2

The returned proxy of the DataContract class also has additional XXXSpecified properties for non-string properties.

Problem 3

Setting a primitive type as return type just has completely unintuitive behaviour. A simple method which returns an integer comes out as a System.Void method, whose results are available through ref parameters.

Is this by design. I’m confused as to why these extra specified params are needed and if not, can they be removed and the int-results-by-ref is just bizarre

Thanks if anyone can shed any light on this design/behaviour.

Answer:

Read this question I asked a long time ago:

Strange behaviour calling method of wcf from powershell using new-webproxyservice

You need to add [XmlSerializerFormat] to the operation contract to avoid additional bool parameters.

Source:

Why is powershell adding additional parameters to Web Service Method Signatures by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply