当多于1个用于装饰方法时,FaultContractAttribute问题 [英] FaultContractAttribute problems when more than 1 used to decorate a method

查看:47
本文介绍了当多于1个用于装饰方法时,FaultContractAttribute问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在用FaultContractAttribute装饰WCF端点接口方法签名.作为示例,我将在下面使用虚构的方法...

[ FaultContract ( typeof ( SystemFaultContract ))]] p

[ FaultContract ( typeof ( ValidationFaultContract )))]

[ OperationContract ]

响应 CheckBob(请求 request);

[ FaultContract ( typeof ( SystemFaultContract ))]] p

[ FaultContract ( typeof ( ValidationFaultContract )))]

[ OperationContract ]

响应 CheckSue(请求 request);

当我执行客户端中的Update Service Refences位时,它仅为方法签名旁边的属性生成代理类.在这种情况下,ValidationFaultContract类.我可以通过在其中一种方法上交换两个FaultContracts的顺序来解决此问题,然后在代理类中生成它.像这样...

[ FaultContract ( typeof ( SystemFaultContract ))]

[ FaultContract ( typeof ( ValidationFaultContract )))]

[ OperationContract ]

响应 CheckBob(请求 request);

[ FaultContract ( typeof ( ValidationFaultContract ))]

[ FaultContract ( typeof ( SystemFaultContract ))]

[ OperationContract ]

响应 CheckSue(请求 request);

我想知道为什么会这样吗?我将这些属性叠加在方法的接口签名上的原因是因为它在O'Reilly WCF书中这样说.是我在生成代理类时遇到问题,还是每个方法只能添加1 FaultContractAttribute?如果是后者,我该如何加2?

干杯,

Adrian Phillips

解决方案

我遇到了完全相同的问题,因为在请求开始时我应该有一个ValidationFaultContract,或者在执行服务本身时可能出现SystemFaultContract错误.
您得到了任何答案吗? ?


 

Hi folks,

 

  I'm decorating my WCF endpoint interface method signatures with the FaultContractAttribute.  As an example I'll use the ficticious methods below...

 

[FaultContract(typeof(SystemFaultContract))]

[FaultContract(typeof(ValidationFaultContract))]

[OperationContract]

Response CheckBob(Request request);

 

[FaultContract(typeof(SystemFaultContract))]

[FaultContract(typeof(ValidationFaultContract))]

[OperationContract]

Response CheckSue(Request request);

 

When I do the Update Service Refences bit in my client, it generates proxy classes for only the attribute next to the method signature.  In this case, the ValidationFaultContract class.  I can fix it by swapping the order of the two FaultContracts on one of the methods, it then gets generated in the proxy classes.  Like so...

 

[FaultContract(typeof(SystemFaultContract))]

[FaultContract(typeof(ValidationFaultContract))]

[OperationContract]

Response CheckBob(Request request);

 

[FaultContract(typeof(ValidationFaultContract))]

[FaultContract(typeof(SystemFaultContract))]

[OperationContract]

Response CheckSue(Request request);

 

I was wondering why this happens?  The reason I'm stacking these attributes up on the method's interface signature is because it says so in the O'Reilly WCF book.  Is the problem I'm seeing a bug in the generation of the proxy classes or can I only add 1 FaultContractAttribute per method?  If it's the latter, how do I add 2?

 

Cheers,

Adrian Phillips

解决方案

I have the same exact problem as I should have a ValidationFaultContract at the beginning of the request and maybe a SystemFaultContract error during the execution of the service by itself.
Did you get any answer?


这篇关于当多于1个用于装饰方法时,FaultContractAttribute问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆