Search code examples
c#wcfwsdlparameters

Can params keyword be expressed via WSDL definition


The application I am developing is exposing service metadata for a WCF service implementing following service contract:

[ServiceContract]
public interface IService
{
    [OperationContract]
    object Execute( string action, params object[] args );
}

After adding service reference I noticed that there is no params keyword in the service contract and its implementation in the generated Reference.cs file.

Is there params counterpart in WSDL definition?

Or is params something that is specific to C# and cannot be expressed via WSDL definition so service client generator does not know that params should be added during generation?


Solution

  • params is just syntactic sugar which allows you calling the method expecting array of objects without passing the prepared array. WCF doesn't know anything about this - it should just expect array of objects. Btw. passing array of object to service operation can leads to multiple problems because if you pass an custom object as parameter WCF may not know how to serialize the object.