title: passing objects in WCF service
body: <p>I am new WCF and resful service. I am learning how to pass objects in WCF service. </p>
  
  <p>I have paste code and web.config file. I dont know why i am seeing this error.</p>
  
  <p>Please help..    </p>
  
  <pre><code>Operation 'saveDataGet' in contract 'IRestServiceImpl' has a query variable named   '  param1' of type 'GainSoft.TaskManager.Service.InputData', but type 'GainSoft.TaskManager.Service.InputData' is not convertible by 'QueryStringConverter'.  Variables for UriTemplate query values must have types that can be converted by 'QueryStringConverter'. 
  Description: An unhandled exception occurred during the execution of the current web request. 
  Please review the stack trace for more information about the error and where it  
  
  originated in the code. 
  
  
  Exception Details: System.InvalidOperationException: Operation 'saveDataGet' in 
  contract 'IRestServiceImpl' has a query variable named 'param1' of type 
  'GainSoft.TaskManager.Service.InputData', but type 
  'GainSoft.TaskManager.Service.InputData' is not convertible by    
   'QueryStringConverter'.  Variables for UriTemplate query values must have types that
   can be converted by 'QueryStringConverter'.
  
  public class RestServiceImpl : IRestServiceImpl
  {
      public string saveDataGet(InputData param1)
      {
          return "Via GET: " + param1.FirstName + " " + param1.LastName;
      }
      public string saveDataPost(InputData param1)
      {
          return "Via POST: " + param1.FirstName + " " + param1.LastName;
      }
  
  
  
      public class MyQueryStringConverter : QueryStringConverter
      {
          public override bool CanConvert(Type type)
          {
              return (type == typeof(InputData)) || base.CanConvert(type);
          }
          public override object ConvertStringToValue(string parameter, Type parameterType)
          {
              if (parameterType == typeof(InputData))
              {
                  string[] parts = parameter.Split(',');
                  return new InputData { FirstName = parts[0], LastName = parts[1] };
              }
              else
              {
                  return base.ConvertStringToValue(parameter, parameterType);
              }
          }
      }
      public class MyWebHttpBehavior : WebHttpBehavior
      {
          protected override QueryStringConverter GetQueryStringConverter(OperationDescription operationDescription)
          {
              return new MyQueryStringConverter();
          }
      }
  
  public interface IRestServiceImpl
  {
  
      [OperationContract]
      [WebGet(UriTemplate = "/InsertData?param1={param1}")]
  
      string saveDataGet(InputData param1);
  
     [OperationContract]
     [WebInvoke(UriTemplate = "/InsertData")]
     string saveDataPost(InputData param1);
   }
  </code></pre>
  
  <p>
        
        
          
          
          
          
        
      </p>
  
  <pre><code>&lt;behaviors&gt;
    &lt;serviceBehaviors&gt;
      &lt;behavior name="ServiceBehaviour" &gt;
        &lt;!-- Add the following element to your service behavior configuration. --&gt;
        &lt;serviceMetadata httpGetEnabled="true" /&gt;
        &lt;serviceDebug includeExceptionDetailInFaults="false"/&gt;
      &lt;/behavior&gt;
    &lt;/serviceBehaviors&gt;
    &lt;endpointBehaviors&gt;
      &lt;behavior name="MyWebHttpBehavior"&gt;
        &lt;webHttp/&gt;
  
      &lt;/behavior&gt;
    &lt;/endpointBehaviors&gt;
  &lt;/behaviors&gt;
  </code></pre>