if your have the following function in WCF. You will need the following input.
[WebInvoke(UriTemplate = "testFunction", Method = "POST",
ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped,
RequestFormat =
WebMessageFormat.Json)]
public string testFunction(string test)
{
Expected Header
User-Agent: Fiddler
Host: localhost:5810
Content-Length: 15
Content-Type: application/json
INPUT:
{"test":"1234"}
OUTPUT:
{"testFunctionResult":"hi, 3\/29\/2011 10:46:56 PM 1234"}
You can make use of fiddler to send http post request. This illustrated the WCF REST function with JSON input and output.
Tuesday, March 29, 2011
Thursday, March 24, 2011
json framework
Simple step to teach you how to implement json framework to parse json string
Example
HTTP POST Restful
NSDictionary *data = [[NSDictionary alloc] initWithObjectsAndKeys:
username, USERNAMEKEY,
password, PASSWORDKEY,
nil];
SBJsonWriter *json = [SBJsonWriter alloc];
NSString *jsonString = [json stringWithObject:data];
NSLog(jsonString);
[data release];
[json release];
//create/send http post request
NSData *postData = [jsonString dataUsingEncoding:NSASCIIStringEncoding];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setURL:[NSURL URLWithString:@"http://abc.appspot.com/api/login/"]];
[request setHTTPMethod:@"POST"];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:postData];
Full article
Example
HTTP POST Restful
NSDictionary *data = [[NSDictionary alloc] initWithObjectsAndKeys:
username, USERNAMEKEY,
password, PASSWORDKEY,
nil];
SBJsonWriter *json = [SBJsonWriter alloc];
NSString *jsonString = [json stringWithObject:data];
NSLog(jsonString);
[data release];
[json release];
//create/send http post request
NSData *postData = [jsonString dataUsingEncoding:NSASCIIStringEncoding];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setURL:[NSURL URLWithString:@"http://abc.appspot.com/api/login/"]];
[request setHTTPMethod:@"POST"];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:postData];
Full article
Subscribe to:
Posts (Atom)