asp.net中web服务wsdl中的默认值

时间:2010-05-10 06:19:11

标签: c# asp.net wcf web-services

我在wcf web服务上创建并尝试使用SOAP UI进行测试。当使用soap ui进行测试时,例如创建员工,如果我使用

发送soap请求xml
<empId>0</empId> works fine. 
<empId></empId> **throwing exception.**
if i completly remove <empId> tag it works fine.... 

有没有办法在WCF中的wsdl中将默认值设为“0”?

NRK

1 个答案:

答案 0 :(得分:1)

谷歌搜索后,我能找到这样的解决方案。 在类中,您需要指定属性,如下所示

[System.ComponentModel.DefaultValue(0)]    
public int EmpId
{
get;set;
}

以下链接帮助我找到解决方案:

http://weblogs.asp.net/pgreborio/archive/2004/01/16/59360.aspx


NRK