我在.Net 4中有一个带有BasicHttpBinding的WCF服务的MVC项目.
在.Net 2中使用此服务时,如果属性为int,则到达的值为0.
如果它是一个字符串,那就好了.
在.Net 4中构建一个新项目,使用相同的服务并使用确切的实现(作为.Net 2)==> int值是正确的.
为什么?
谢谢!
我打赌你有一个具有实际int属性的数据合同:
public int YourProperty ......
Run Code Online (Sandbox Code Playgroud)
以及YourPropertySpecified它旁边的财产:
public bool YourPropertySpecified ......
Run Code Online (Sandbox Code Playgroud)
由于a int不能为null,WCF无法区分您是否已定义值 - 您需要告诉它.
因此,如果您使用int属性并为其设置值 - 您还需要将其伴随YourPropertySpecified属性设置为true:
yourData.YourProperty = 42;
yourData.YourPropertySpecified = true;
Run Code Online (Sandbox Code Playgroud)
通过这个额外的步骤,int值应该到达服务器就好了
| 归档时间: |
|
| 查看次数: |
2187 次 |
| 最近记录: |