Portable / Interoperable WCF Contracts

前端 未结 2 1634
暗喜
暗喜 2021-02-06 04:36

I was wondering if anybody out there had some good tips/dos and don\'ts for designing WCF contracts with a mind for web-service interoperability, both in terms of older Microsof

2条回答
  •  野性不改
    2021-02-06 05:12

    WCF DateTime woes

    Regarding your DateTime question, you are right to be concerned about passing around DateTime via WCF. This is just one link of many that gripe about the difficulties... http://daveonsoftware.blogspot.com/2008/07/wcf-datetime-field-adjusted.html

    Regarding Type Equivalence

    According to section 3.1.3 of Juval Lowy's book entitled Programming WCF Services, 2nd Edition...

    WCF offers implicit data contracts for the primitive types because there is an industry standard for the schemas of those types.

    He also points that out in regards to the use of custom types as parameters on Operation Contract methods. I presume this also applies to method return types.

    To be able to use a custom type as an operation parameter, there are two requirements: first, the type must be serializable, and second, both the client and the service need to have a local definition of that type that results in the same data schema.

    You may also want to check out section F.4. Data Contracts, which is part of his WCF Coding Standard. Bullet #9 applies to your question...

    Do not pass .NET-specific types, such as Type, as operation parameters.

    Bindings Establish Expectations

    Bindings that are based on WSHttpBindingBase (search in Reflector.NET for its four derivations) are going to be the most interoperable, since they are designed for interoperability.

    Book Recommendation

    I highly recommend Juval's book: http://www.bookpool.com/sm/0596521308

提交回复
热议问题