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.
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<IMyService> factory = new ChannelFactory<IMyService>(binding, endpoint);
IMyService channel = factory.CreateChannel();
channel.InsertTest(testobject);
I am getting the following error:
'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.
Anyone had experience trying to do this? Or any ideas on what I am doing wrong?