I'm trying to make my app send data to a WCF RESTful webservice.
At this point I'm not getting any error message from ASIHTTPRequest but the web service not doing anything either.
Could you guys take a look at it and see if you can spot something?
Xcode
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>some body</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];
Webservice
...
public class Product { [DataMember] public string Id { get; set; }
[DataMember]
public string Name { get; set; }
[DataMember]
public string Description { get; set; }
}
...
[OperationContract] [WebInvoke(UriTemplate = "/create", Method = "POST", RequestFormat=WebMessageFormat.Xml, BodyStyle=WebMessageBodyStyle.Bare)] void CreateProduct(Product product);
...
...CreateProduct...
myConnection.Open();
string insertString = "insert into tbldata (desc,Name) values (@desc,@Name)";
MySqlCommand myCommand = new MySqlCommand(insertString, myConnection);
myCommand.Parameters.Add("@desc", MySqlDbType.VarChar, 12);
myCommand.Parameters.Add("@Name", MySqlDbType.VarChar, 40);
myCommand.Parameters["@desc"].Value = product.Description;
myCommand.Parameters["@Name"].Value = product.Name;
myCommand.ExecuteNonQuery();