I would like to consume a third-party restful web service which exposes methods for GET requests. GET request are to be performed within a windows service + Timer and they all return JSON.
I would like, if possible, use WCF libraries for the de-serialization of JSON -> POCO whilst implementing forward-compatibility. The latter is implemented, as far as I understand, via DataContracts which implement IExtensibleDataObject. Can I use this approach to consume 3rd party restful (JSON) web services?
Any feedback appreciated. Thanks.
Sounds like you’re trying to use the WCF client-side libraries to consume the third party service. The WCF client-side libraries were designed to use a defined service contract, either from a WSDL document or from an assembly with a
ServiceContractclass and relatedOperationContractandDataContractmarked methods & classes. You can use the client-side libraries to consume JSON but you’d almost would have to “re-create” the third party service as a soap based service to produce the WSDL or writeServiceContractassembly for the service contract.Look at this short CodeProject article to see how to create a WCF JSON outputing service and how to configure the WebHttpBinding in WCF.
As to using the
IExtensibleDatObjectwith JSON, this other CodeProject article has some good infomation but I don’t think its applicable to your scenario since you would have to control the third party service contract.