Peter Vitt

Peter Vitt

  • NA
  • 3
  • 1.1k

wcf Service method that accepts a class parameter via POST

Jun 30 2014 5:12 PM
Hi - I'm having difficulty trying to get a WCF service method to read a class input parameter via a POST.  I'm calling this method from a dojo xhr post sending JSON to the service -- I keep getting a 500 error saying unable to load the service. 

My interface looks like this:
[OperationContract]
        [WebInvoke(Method = "POST",
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Wrapped,
            UriTemplate = "AirVacInspectionInsert/{av}")]
            String AirVacInspectionInsert(AVInspectionData av);

and my method looks like this:

 public String AirVacInspectionInsert(AVInspectionData av)
        {
            //do something here
        }

if I leave out the /av in the UriTemplate the page will load, but av is always null.  Is there some trick to reading the post data?  will the method not accept JSON formatted exactly like my class AVInspectionData as an input parameter?  Any ideas much appreciated.  I've gotten my wcf service to work fine accepting text via GET

Thanks





Answers (1)