-1

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 that 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!

John Saunders
  • 160,644
  • 26
  • 247
  • 397
Ryan
  • 165
  • 1
  • 11
  • So what I did was I created a webservice layer on the top of the BusinessLayer and was able to get the response from the database. This way I avoided creating own business layer. But I get a WCF deserilization error during getting a response from the webservice. – Ryan Jan 20 '11 at 16:54
  • This is due to the complex datatype 'Category' I am receiving from the webservice. Actually I am retrieving a generic List from the webservice. This gives me the serelization/deserialization errors. Each Category type item itself contains other types of objects returned like - CategoryTemplate, Discount, Picture, List and a few more which are causing me the problems. – Ryan Jan 20 '11 at 16:55
  • WCF _is_ web services. You mean WCF vs. old, legacy ASMX web services. – John Saunders Jan 20 '11 at 18:50
  • please add your specific problem to your question. You should be able to serialize any reasonable set of types, so let us help you to make it work in WCF. – John Saunders Jan 20 '11 at 18:51

1 Answers1

0

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.

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798