Hello All,
I have a concern in passing complex objects/any other types: because I always get a bad request...Code snippet below:
Service:
[OperationContract]
[WebInvoke(UriTemplate = "saveXML/", Method="POST", BodyStyle= WebMessageBodyStyle.Bare)]
bool saveXML(XElement xmlString)
{
return true;
}
=========
Client:
private HttpUrlEncodedForm frm = new HttpUrlEncodedForm();
frm.Add("CustomerCode", "123");
frm.Add("CustomerName", "Joseph");
frm.Add("Address", "4th Street Washington Ave. New York");
frm.Add("Country", "United States of America");
using (HttpResponseMessage response = m_RestHttpClient.Post("saveXML/", frm.CreateHttpContent()))
{
response.EnsureStatusIsSuccessful();
}
or I tried it this way:
var request = new XDocument(
new XElement("Customer",
new XElement("CustomerCode", "123"),
new XElement("CustomerName", "Joseph"),
new XElement("Address", "4th Street Washington Ave. New York"),
new XElement("Country", "United States of America")));
frm.Add("body", request.ToString());
..both ways did not work....this is just a sample i want to use complex types because i will be passing atleast 50 parameters...or if you have any other suggestions feel free to suggest.
Thank you
Best Regards, Ravi