Lord Vermillion Lord Vermillion - 13 days ago 6
C# Question

WCF required parameters in wsdl

Assume i have a method in my WCF Service:

[OperationContract]
ResponseObj Test(string testString);


When i add this WSDL to soapUI the testString will be marked as optinal

<tem:Test>
<!--Optional:-->
<tem:testString>?</tem:testString>
</tem:Test>


How do i make the testString parameter required?
Do i need to add something in the OperationContract method? Or are all parameters Optional in the request in soapUI?

Answer

use data contract with IsRequired attribute for the properties

[OperationContract]
ResponseObj Test(RequestMessage request);


[DataContract]
public class RequestMessage
{
   [DataMember(IsRequired = true)]
   public string TestString{ get; set; }
}
Comments