3

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

yrahman
  • 960
  • 5
  • 15
  • 33

2 Answers2

2

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.

carlosfigueira
  • 85,035
  • 14
  • 131
  • 171
0

This blog post seems to cover what you're looking for.

http://saravananarumugam.wordpress.com/2011/03/04/simple-rest-implementation-with-webhttpbinding/

J. Mitchell
  • 340
  • 4
  • 14
  • this link only tells about sending basic data types. i want to send object of employee class in browser based url. so it doesn't fulfill my requirements – yrahman Oct 30 '11 at 06:19
  • Serialize your custom objects by using the Serializable attribute on the custom classes. Then, just serialize the object using System.Xml.Serialization.XmlSerializer Hope that points you in the right direction – J. Mitchell Jan 11 '12 at 00:26