简体   繁体   中英

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?

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

您仍然可以在调用中省略“ request”参数,并在服务器端获取一个空对象。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM