This question already has answers here:
Closed 5 years ago.
i have a serializable entity class of employee
public class Emp
{
public int Id{get; set;}
public string Name{get;set;}
}
i want to send object of this class to WCF REST Services from browser to test my add method which is given below
[WebInvoke(Method = "POST", UriTemplate = "Employee/")]
[OperationContract]
string SaveEmployee(Emp Employee);
can anyone please tell me how to send custom object to WCF REST Service in browser based url
If you want to send the complex object in the URL (not in the message body), first of all, this is usually a bad idea (objects can be large, URIs have a size limit which you may end up hitting). But if this is really what you want, you can use a custom QueryStringConverter
in your service which will know how to convert between the query string parameters and your object.
You can find more information about query string converters at http://blogs.msdn.com/b/carlosfigueira/archive/2011/08/09/wcf-extensibility-querystringconverter.aspx.
This blog post seems to cover what you're looking for.
http://saravananarumugam.wordpress.com/2011/03/04/simple-rest-implementation-with-webhttpbinding/