How can I force WCF to autogenerate WSDLs with required method parameters (minoccurs=“1”)?

后端 未结 2 1813
太阳男子
太阳男子 2020-12-05 11:03

While using WCF and OperationContracts I have the following method defined:

    [OperationContract]
    [FaultContract(typeof(ValidationFault))]
    [FaultCo         


        
2条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-05 11:52

    I've just written a Blog post about this subject, as I ran into the problem myself last week. It explains how you can modify the metadata that WCF generates at runtime.

    Aside from downloading the source file, you only need to add an attribute to your contract definition. Like so:

    [ServiceContract]
    [RequiredParametersBehavior]
    public interface ICalculatorService
    {
        [OperationContract]
        int Add(int firstValue, int secondValue);
    }
    

    Here's the Blog post that explains it in more detail: Controlling WSDL minOccurs with WCF

提交回复
热议问题