c# - How to specify a parameter of an OperationContract as required -


I wonder how can I specify the parameters of the operation contract method in WCF so that xsd generated minOccurs = "1 Example:

  [communication of service (namespace = "http://myUrl.com")] Public Interface IMyWebService {[Operation Contract] string DoSomething (string Absolute 1, string paragraph 2, string paragraph 3); }  

Generates the XSD:

   & Lt; Xs: element minimum orchars = "0" name = "absolute 2" nilibble = "true" type = "x: string" /> & Lt; Xs: element min octaurus = "0" name = "absolute 3" nilele = "true" type = "x: string" /> & Lt; / XS: sequence & gt; & Lt; / XS: complexType & gt;  

But I want to define minOccurs = "1" in the code without needing to manually fix it in the xsd file.

You may need to wrap your parameters in the class, then you DataMember attribute and specify IsRequired = true :

  [communication of service (namespace = "http://myUrl.com" )] Public Interface IMyWebService {{OperationContract} string DoSomething (RequestMessage Request); } [DataContract] Public class request message [[DataRequired = true] Public string parameter1 {get; Set; } [DataMember (IsRequired = true)] Public String param3 {get; Set; } [DataMember (IsRequired = true)] Public String param3 {get; Set; }}  

Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -