Not sure how to send complex data using web services

I looked through a few questions on the site, but it’s still hard for me to figure out where to start.

I have never done anything with web services before, so bear with me.

The current project I'm assigned to is to write a web service that queries the database and returns data to the client. (using .NET 2008 programming in C #)

So far, I have not been able to create basic data types, but I'm not 100% sure where to go from there. I am returning an XmlDocument type, but I'm not sure if this is the best way or even the right way to do it.

An ASP.NET web service is currently being created, although it has been proposed to use the WCF web service.

Can anyone shed light on where to go? Or perhaps a link to a tutorial on sending and receiving large amounts of data through webservices?

EDIT: The answer so far is wonderful, but I'm still not 100% sure how to answer. I think that the web service will interact with a combination of client programs, but also with websites, if this is all possible ... This is how I feel about it.

+3
source share
5 answers

Depending on the structure of the data that you send back to the client, I would not recommend using it XmlDocumentas the return type. This will add a lot of unnecessary volume to your answer.

, , HTTP, , JSON .

, , JSON, :

[WebGet(ResponseFormat=WebMessageFormat.Json, UriTemplate="GetComplexObject/{id}")]
public MyComplexType GetComplexObject(int id){
  //do work to get your object
  return myObject;
}

WCF JSON, MyComplexType DataContract...

[DataContract]
public class MyComplexType{
  [DataMember]
  String Name {get;set;}
}

REST-ful, WCF, , , WebHttp.

WCF WCF WebHttp ( .NET 4). -, , , .

, ! .

+2

xml, , XML-.

-, - , , , - .

- json.

0

, - ASPX.NET:

  • - -.

  • / ( XML, JSON )

, , . - , , / . , , -, - -, . , , , , .

- , . , . , . , XML . , XML . . , / -, .

WCF . . , -.

0

All Articles