別のサーバーでホストされているWCFサービスを呼び出すDynamicsCRM2011のプラグインを作成しました。以下は私のプラグインのコードです。プラグインのクラスライブラリでは、サービス参照を使用していませんが、svcutil.exeを使用してWCFクライアントを生成しました。
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);
次のエラーが発生します。
'System.Threading.Tasks.Task`1[System.Int32]'はシリアル化できません。DataContractAttribute属性でマークを付け、シリアル化するすべてのメンバーをDataMemberAttribute属性でマークすることを検討してください。タイプがコレクションの場合は、CollectionDataContractAttributeでマークすることを検討してください。サポートされている他のタイプについては、Microsoft.NETFrameworkのドキュメントを参照してください。
誰かがこれをやろうとした経験がありますか?または私が間違っていることについてのアイデアはありますか?