开发者

WCF Basic Contract Design Question

I'm new to WCF and I am creating my first (basic) service, which is create / update user. I'm wondering which path to go when designing my contracts. here are my two options:

void Create(User user);
// or
CreateResponse Create(Cre开发者_StackOverflowateRequest request);

Now, if I go the second route, do I still use faults or do i wrap up any exceptions in the response object?

Any ideas would be great!


It's a matter of choice.

If you use faults, remember that whenever a fault occurs, your client-side proxy will be in faulted state -- i.e., you will always have to create a fresh one and dispose it as soon as you don't need it anymore.

In case you do not use faults, you must make sure to always process the validation result stored in the Response objects.

The validation result approach has the additional advantages that you can store multiple validation results (or multiple exceptions/error messages) in it, and that it remains completely independent of .NET.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜