I have posted a question earlier but unfortunately I did not get any useful answer so I'll try in a different way. Here's the scenario.
I've a simple WCF RESTful service set up on a hosted environment.
I'm trying to communicate with this service from iphone 4. Here's what is working.
I have two uri template set up. One for GET and one for POST.
Running a console app on my local machine I'm able to GET and POST data. The data being extracted from the request and sent to a mysql database.
On the iphone I'm able to GET data.
Unrotunately I'm not able to POST data from the iphone.
I've been trying to make ASIHTTPResuest working. When I'm sending the request I get responseStatusCode 200 back.
I tried to create the request using NSmutableTableRequest but that didn't work either. Request was sent no error.
At this point I'm assuming that the POST request is correct as I'm not getting any error but somehow the webservice are not able to get the data out of the XML body.
I'm still in the middle of the WCF learning process so I got to miss something "basic" here.
Would this Datacontract and Operationcontact
[OperationContract]
[WebInvoke(UriTemplate = "/create",
Method = "POST", RequestFormat=WebMessageFormat.Xml,
BodyStyle=WebMessageBodyStyle.Bare)]
void CreateProduct(Product product);
....
[DataContract(Namespace="")]
public class Product {
[DataMember]
public string Id { get; set; }
[DataMember]
public string Name { get; set; }
[DataMember]
public string Description { get; set; }
}
be able to read this message?
NSURL *url = [NSURL URLWithString:@"http://www.mydomian.com/create"];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
NSData *myPostData = [[NSString stringWithFormat:@"<Product><Description>desc1</Description><Id></Id><Name>somebody</Name></Product>"] dataUsingEncoding:NSUTF8StringEncoding];
NSMutableData *myMutablePostData = [NSMutableData dataWithData:myPostData];
[request setPostBody:myMutablePostData];
[request setRequestMethod:@"POST"];
[request addRequestHeader:@"Content-Type" value:@"application/xml"];
[request setDelegate:self];
[request startSynchronous];
Literally any help would be greatly appriciated.