json - calling method webService (WCF) from iOS objective C) -
i want calling method webservice parameter json ios, received error.
code server side (wcf):
[operationcontract] [webget(responseformat = webmessageformat.json, uritemplate = "/test/{input}")] int test(string input);
i want input (parameter method , url) = typeof (json)
code client side (ios-objective c) :
nsstring *json = [self converttojson:myobject]; nsstring *urlcomplete = [nsstring stringwithformat:@"%@%@",@"http://test.com/service.svc/test/",json]; urlcomplete = [urlcomplete stringbyaddingpercentescapesusingencoding:nsutf8stringencoding]; nsmutableurlrequest *request = [[nsmutableurlrequest alloc]init]; [request seturl:[nsurl urlwithstring:urlcomplete]]; [nsurlconnection sendasynchronousrequest:request queue:[nsoperationqueue mainqueue] completionhandler: ^(nsurlresponse *response, nsdata *data, nserror *connectionerror) { if (data.length > 0 && connectionerror == nil) { nsstring *string = [[nsstring alloc]initwithdata:data encoding:nsasciistringencoding]; nslog(@"data recived:\n %@",string); } else{ nslog(@"error %@",[connectionerror description]); } }];
the webservice being tested windowsphone , returns ok doesn't work ios. please me! thanks:)
error description "http error 400. request url invalid." clears url passing incorrect. please cross check windows team if appending json url.
generally, if want post data can set requestdata json , go either put or post request instead of request.
Comments
Post a Comment