title: How to post complex type to WCF using Python's requests?
body: <p>I am trying to query a WCF web service using Python's <a href="http://www.python-requests.org/en/latest/user/quickstart/" rel="nofollow">request</a> package.</p>
  
  <p>I created a very simple web service in WCF, following the default VS template:</p>
  
  <pre><code>[ServiceContract]
  public interface IHWService
  {
  
      [OperationContract]
      [WebInvoke(Method="GET", UriTemplate="SayHello", ResponseFormat=WebMessageFormat.Json)]
      string SayHello();
  
      [OperationContract]
      [WebInvoke(Method = "POST", UriTemplate = "GetData", ResponseFormat = WebMessageFormat.Json)]
      string GetData(int value);
  
      [OperationContract]
      [WebInvoke(Method = "POST", UriTemplate = "GetData2", BodyStyle=WebMessageBodyStyle.Bare,  RequestFormat=WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
      CompositeType GetDataUsingDataContract(CompositeType composite);
  
      // TODO: Add your service operations here
  }
  </code></pre>
  
  <p>From Python, I manage to call the first two and get the data back easily.</p>
  
  <p>However, I am trying to call the third one, which adds the concept of complex types.</p>
  
  <p>This is my python code:</p>
  
  <pre><code>import requests as req
  import json
  
  wsAddr="http://localhost:58356/HWService.svc"
  methodPath="/GetData2"
  
  cType={'BoolValue':"true", 'StringValue':'Hello world'}
  headers = {'content-type': 'application/json'}
  result=req.post(wsAddr+methodPath,params=json.dumps({'composite':json.dumps(cType)}),headers=headers)
  </code></pre>
  
  <p>But it does not work, i.e., if I put a breakdown in VS in the <code>GetDataUsingDataContract</code> method, I see that the <code>composite</code> argument is <code>null</code>. I think this comes from a problem in parsing, but I can't quite see what's wrong.</p>
  
  <p>Do you see an obvious mistake there?</p>
  
  <p>Do you know how I can debug inside the parsing mechanism?</p>
  
  <p><strong>EDIT</strong>:</p>
  
  <p>Here is the complex type definition:</p>
  
  <pre><code>[DataContract]
  public class CompositeType
  {
      bool boolValue = true;
      string stringValue = "Hello ";
  
      [DataMember]
      public bool BoolValue
      {
          get { return boolValue; }
          set { boolValue = value; }
      }
  
      [DataMember]
      public string StringValue
      {
          get { return stringValue; }
          set { stringValue = value; }
      }
  }
  </code></pre>