Portable / Interoperable WCF Contracts

血红的双手。 提交于 2019-12-03 03:52:26

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

So if you want to interop with non microsoft services you will probably want to steer clear of any non-primitive type. WCF uses serialization to encode data for transmission and Java for instance will not be able to deserialize a hashtable. WCF however is build on top of SOAP so with a bit of work you should be able to get any SOAP feature working between a JAVA client and WCF Service or vice-versa.

Just remember to compose contracts of primitives and you should do okay.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!