Optional parameters in ASP.NET web service

前端 未结 2 1540
旧时难觅i
旧时难觅i 2020-12-11 16:09

I have a ASP.NET web service. This web service works fine. However, the WSDL lists some parameters as optional (minoccurs = 0) and others as non-optional. Some of the option

2条回答
  •  鱼传尺愫
    2020-12-11 16:44

    I am assuming that when you say ASP.net web services, you are creating web services with ASMX extension. I think that what happens in this case is that all nullable types become optional and non-nullable become non-optional.

    You could perhaps manually edit the generated WSDL file. But then you would have to redo that work if the wsdl was regenerated.

    I would suggest that you switch to WCF with basisHttpBinding (except for the name of you service your clients should not notice the difference).

    Using WCF you can simply mark the parameter in the data contract as required or not:

    [DataMember(IsRequired="false")]
    

提交回复
热议问题