objective c - Can't obtain a response from WCF service -


i have trouble when try call web service made in wcf, service calling mac os x app.

this code

soapmessage = @"{name:\"sergio\"}";  nsurl *url = [nsurl urlwithstring:@"http://localhost/gsbonoservicios/gsbonoservice.svc/helloworld"]; nsmutableurlrequest *therequest = [nsmutableurlrequest requestwithurl:url]; nsstring *msglength = [nsstring stringwithformat:@"%d", [soapmessage length]]; [therequest sethttpmethod: @"post"]; [therequest setvalue:@"application/json" forhttpheaderfield:@"accept"]; [therequest setvalue:@"application/x-www-form-urlencoded" forhttpheaderfield:@"content-type"]; nsdata *requestdata = [nsdata datawithbytes:[soapmessage utf8string] length:[soapmessage length]]; [therequest sethttpbody:requestdata]; nsurlconnection *theconnection = [[nsurlconnection alloc] initwithrequest:therequest delegate:self]; 

the connection successful didn't response, try implementing tutorials , i'm looking in stackoverflow , find many answers nothing works, hope can me.

ps. not speak english, hope explained, thanks

finally found solution problem in service, , code works is

nsstring *name=@"sergio"; nsdictionary *tmp = [[nsdictionary alloc] initwithobjectsandkeys: name, @"name",                  nil]; nsurl *url = [nsurl urlwithstring:@"http://www.myserver.com/servicio/servicioejemplo.svc/helloworld"]; nsmutableurlrequest *therequest = [nsmutableurlrequest requestwithurl:url]; [therequest sethttpmethod: @"post"]; [therequest setvalue:@"application/json" forhttpheaderfield:@"accept"]; [therequest setvalue:@"applicat ion/json" forhttpheaderfield:@"content-type"]; nserror *error; nsdata *postdata = [nsjsonserialization datawithjsonobject:tmp options:kniloptions error:&error]; [therequest sethttpbody:postdata]; nslog(@"json summary: %@", [[nsstring alloc] initwithdata:postdata                                              encoding:nsutf8stringencoding]); nsurlconnection *theconnection = [[nsurlconnection alloc] initwithrequest:therequest delegate:self]; 

thanks


Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -