WCF Data Services - WebInvoke Method RRS feed

  • Question

  • User-1080777599 posted

    I am using a WCF Data Service to insert data into the Databse via Entity Framework 5.0.

    I need to insert an Object of type Employee to the Employee Table using a WebInvoke method.

    But WebInvoke method is not allowing custom objects as input parameters. It says 'Only primitive data types are allowed'.

    How do I pass this parameter to the service side or should I use some other method for this?

     For eg:-

     [WebInvoke(Method = "POST")]        

    public int AddEmployee(Employee Obj)  


      return 1;      




    Tuesday, May 7, 2013 5:05 AM


All replies

  • User-488622176 posted

    you could use serialization. Meaning:

    • Convert the object "Obj" to an xml string (using the XmlSerializer)
    • Change "AddEmployee(Employee Obj)" to "AddEmployee(String employeeStr)"
    • Deserialize in the implementation

    Or instead of Xml serialization, you can apply json serialization, ...

    Tuesday, May 7, 2013 9:08 AM
  • User-1662538993 posted

    You can define youe employee class with DataContract -

    class Employee
        // properties as data member here

    Tuesday, May 7, 2013 12:23 PM
  • User-1000095884 posted


    Since this issue is related to WCF Data Service, I would suggest you post you question here


    There are more professionals on this issue, so you can get better support there. Thanks for your understanding and support.

    Best Regards.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, May 7, 2013 10:15 PM