title: Calling WCF service from dynamics crm 2011 plugin
body: <p>I have written a plugin for Dynamics CRM 2011 that calls a WCF service hosted on a different server. Below is the code in my plugin. In the class library for the plugin I have not used a service reference but used svcutil.exe to generate a WCF client.</p>
  
  <pre><code>var binding = new BasicHttpBinding();
  binding.Name = "BasicHttpBinding_IMyService";
  binding.Security.Mode = BasicHttpSecurityMode.None;
  binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
  binding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None;
  binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
  var endpoint = new EndpointAddress("http://test/MyService.svc");
  ChannelFactory&lt;IMyService&gt; factory = new ChannelFactory&lt;IMyService&gt;(binding, endpoint);
  IMyService channel = factory.CreateChannel();
  channel.InsertTest(testobject);
  </code></pre>
  
  <p>I am getting the following error:</p>
  
  <p>'System.Threading.Tasks.Task`1[System.Int32]' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute.  If the type is a collection, consider marking it with the CollectionDataContractAttribute.  See the Microsoft .NET Framework documentation for other supported types.</p>
  
  <p>Anyone had experience trying to do this? Or any ideas on what I am doing wrong?</p>