Restful Web Service:
Case 1: It is not work on Add reference process
Case 2: It is not use soap protocol
Case 3: It is Call by HttpWebRequest HttpWebResponse
Case4: In this case get post method are use for getting response and request.
The Methods
Case 2: It is not use soap protocol
Case 3: It is Call by HttpWebRequest HttpWebResponse
Case4: In this case get post method are use for getting response and request.
The Methods
The interface of REST is generic. There is no need for protocol conventions for the communication between client and server. The following list describes the meaning of the HTTP methods and how they are used by REST.
Table 1: HTTP Methods | |
Method | Description |
GET | GET queries the representation of a resource. The execution of requests should be free from side effects. GET requests can be sent arbitrarily often. You cannot blame the client for effects caused by GET requests. That means a GET can be sent heedlessly. |
POST | With POST you can change the state of a resource. For example you can add a good to a shopping cart. POST isn't free from side effects. For example you can change fields in a data base or start a new process on the server with a POST request. |
PUT | New resources can be produced with PUT or you can replace the content of existing resources. |
DELETE | Resources can be deleted using DELETE. |
How to call:
Case: 1 First Request Format
1: text
2: Xml
3: html
2: Xml
3: html
Case 2: Check your query string name for send request or any variable name
Case 3: url of rest web service
Method: For Xml Format
private string PostData_new(string url, string postData)
{
HttpWebRequest request = null;
Uri uri = new Uri(url);
request = (HttpWebRequest)WebRequest.Create(uri);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = postData.Length;
using (Stream writeStream = request.GetRequestStream())
{
UTF8Encoding encoding = new UTF8Encoding();
byte[] bytes = encoding.GetBytes(postData);
writeStream.Write(bytes, 0, bytes.Length);
}
string result = string.Empty;
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
using (Stream responseStream = response.GetResponseStream())
{
using (StreamReader readStream = new StreamReader(responseStream, Encoding.UTF8))
{
result = readStream.ReadToEnd();
}
}
}
return result;
}
Call function:
Postdate=”variable name/Query string name=your date”
No comments :
Post a Comment