Complex Objects - Which is best Web Services or WCF?
I have a complex set of Library files that work with a large existing web site. What I'm trying to do is create web services that mimic the functionality of the website so that I can work on creating a mobile application as well.
The issue t开发者_如何学Gohat I'm running into is that we can't serialize the complex objects I have created with the website. What is the best work around to re-coding the entire object structure into a serialized fashion. Would WCF be appropriate solution? I'm not very familiar with them so any details would be really helpful.
Any other ideas would great, or if there are any other tools available we can buy to help us with a solution.
Thanks in advance!
For me the WCF is clear favorite for your purpose. The main advantage of the usage WCF in your case I see the ability to return any data of any ContentType. Moreover WCF supports streaming of returned data which could also be very helpful if the size of file which you want to return from the service is large.
WCF allows you return data of the type Stream
or Message
. In the case you can set manually the WebOperationContext.Current.OutgoingResponse.ContentType
to the value which you need ("image/jpeg" or "image/png" for example). You can find many example like this which demonstrate the technique. If you use .NET 4.0 you can use CreateTextResponse, CreateStreamResponse or other WebOperationContext Methods
See old answers: this, this and this as additional examples.
精彩评论