Lord Vermillion
Lord Vermillion

Reputation: 5414

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?

Upvotes: 2

Views: 1965

Answers (2)

Robert
Robert

Reputation: 515

You can still omit the "request" parameter in the call and get a null object at the server side.

Upvotes: 1

Damith
Damith

Reputation: 63065

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; }
}

Upvotes: 3

Related Questions