В настоящее время у нас есть приложение, в котором есть серверное приложение, которое предоставляет службу REST WCF, а затем у нас есть клиентская сторона, которая взаимодействует со службами REST WCF на сервере. В настоящее время я получаю сообщение об ошибке на стороне клиента, которое не могу выяснить, и мне не повезло в поиске ответов в Google.
Как только я вызываю ChannelFactory для создания канала, выдается следующее исключение. Кто-нибудь знает, что означает эта ошибка и где я могу найти что-то, что может помочь мне решить проблему? Ниже также приведен общий метод, который мы используем для вызова сервиса со стороны клиента. Fiddler не показывает никаких сообщений, исходящих от клиента, поэтому проблема находится непосредственно на стороне клиента. Сервер и клиент совместно используют один и тот же интерфейс для связи.
System.InvalidOperationException was caught
HResult=-2146233079
Message=New types cannot be registered with serializer manager after the service has been opened.
Source=System.ServiceModel.Web
StackTrace:
at System.ServiceModel.Dispatcher.UnwrappedTypesXmlSerializerManager.RegisterType(Object key, IList`1 types)
at System.ServiceModel.Dispatcher.SingleBodyParameterXmlSerializerMessageFormatter..ctor(OperationDescription operation, Type parameterType, Boolean isRequestFormatter, XmlSerializerOperationBehavior xsob, UnwrappedTypesXmlSerializerManager serializerManager)
at System.ServiceModel.Dispatcher.SingleBodyParameterMessageFormatter.CreateXmlFormatter(OperationDescription operation, Type type, Boolean isRequestFormatter, UnwrappedTypesXmlSerializerManager xmlSerializerManager)
at System.ServiceModel.Dispatcher.SingleBodyParameterMessageFormatter.CreateClientFormatter(OperationDescription operation, Type type, Boolean isRequestFormatter, Boolean useJson, UnwrappedTypesXmlSerializerManager xmlSerializerManager)
at System.ServiceModel.Description.WebHttpBehavior.<>c__DisplayClass7.<>c__DisplayClassa.<GetRequestClientFormatter>b__4()
at System.ServiceModel.Description.WebHttpBehavior.<>c__DisplayClass7.<GetRequestClientFormatter>b__3()
at System.ServiceModel.Description.WebHttpBehavior.HideReplyMessage(OperationDescription operationDescription, Effect effect)
at System.ServiceModel.Description.WebHttpBehavior.GetRequestClientFormatter(OperationDescription operationDescription, ServiceEndpoint endpoint)
at System.ServiceModel.Description.WebHttpBehavior.ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime)
at System.ServiceModel.Description.DispatcherBuilder.ApplyClientBehavior(ServiceEndpoint serviceEndpoint, ClientRuntime clientRuntime)
at System.ServiceModel.Description.DispatcherBuilder.BuildProxyBehavior(ServiceEndpoint serviceEndpoint, BindingParameterCollection& parameters)
at System.ServiceModel.Channels.ServiceChannelFactory.BuildChannelFactory(ServiceEndpoint serviceEndpoint, Boolean useActiveAutoClose)
at System.ServiceModel.ChannelFactory.CreateFactory()
at System.ServiceModel.ChannelFactory.OnOpening()
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open()
at System.ServiceModel.ChannelFactory.EnsureOpened()
at System.ServiceModel.ChannelFactory`1.CreateChannel(EndpointAddress address, Uri via)
at System.ServiceModel.ChannelFactory`1.CreateChannel()
at Enterprise.ServiceModel.ChannelFactoryExtensions.ExecuteRequest[TChannel,TResult](ChannelFactory`1 factory, Func`2 readDelegate) in C:\Users\User 1\Desktop\Foo_TFS\Foo 5.1\Trunk\Enterprise.Common\ServiceModel\ChannelFactoryExtensions.cs:line 115
at Foo.Service.Client.FooDataMessenger.RetrieveAircraft() in C:\Users\User 1\Desktop\Foo_TFS\Foo 5.1\Trunk\Foo.Service.Client\Client\FooDataMessenger.cs:line 699
at Foo.Service.Client.FooDataMessenger.<ReadAircraft>b__3() in C:\Users\User 1\Desktop\Foo_TFS\Foo 5.1\Trunk\Foo.Service.Client\Client\FooDataMessenger.cs:line 95
at Enterprise.DelegateHelpers.ElapsedFunc[TOut](Func`1 actionDelegate, TOut& result) in C:\Users\User 1\Desktop\Foo_TFS\Foo 5.1\Trunk\Enterprise.Common\Extensions\DelegateHelpers.cs:line 103
at Enterprise.DelegateHelpers.ElapsedFuncTrace[TOut](Func`1 actionDelegate, String location, String method, String action) in C:\Users\User 1\Desktop\Foo_TFS\Foo 5.1\Trunk\Enterprise.Common\Extensions\DelegateHelpers.cs:line 128
at Foo.Service.Client.FooDataMessenger.ReadAircraft() in C:\Users\User 1\Desktop\Foo_TFS\Foo 5.1\Trunk\Foo.Service.Client\Client\FooDataMessenger.cs:line 91
at Foo.Service.FooServiceClientData.ReadAircraft() in C:\Users\User 1\Desktop\Foo_TFS\Foo 5.1\Trunk\Foo.Service.Client\FooServiceClientData.cs:line 215
at Foo.Config.Data.InternalDatumController.get_Aircraft() in C:\Users\User 1\Desktop\Foo_TFS\Foo 5.1\Trunk\Foo.Config.Data\InternalDatumController.cs:line 90
at Foo.Config.Data.Sync.AircraftDefsSyncView.ReadData() in C:\Users\User 1\Desktop\Foo_TFS\Foo 5.1\Trunk\Foo.Config.Data\Sync\FooData\AircraftDefsSyncView.cs:line 81
at Foo.Synchronization.Databases.Base.SyncProvider.ReadViewData(String viewName, Int32 batchCount) in C:\Users\User 1\Desktop\Foo_TFS\Foo 5.1\Trunk\Foo.Synchronization\Databases\Base\SyncProvider.cs:line 88
at Foo.Synchronization.Databases.Base.SyncOrchestrator.Synchronize() in C:\Users\User 1\Desktop\Foo_TFS\Foo 5.1\Trunk\Foo.Synchronization\Databases\Base\SyncOrchestrator.cs:line 114
at Foo.Synchronization.Plugin.Synchronizer.Synchronize_FooData() in C:\Users\User 1\Desktop\Foo_TFS\Foo 5.1\Trunk\Foo.Synchronization.Plugin\Synchronizer.cs:line 201
at Foo.Synchronization.Plugin.Synchronizer.Sync() in C:\Users\User 1\Desktop\Foo_TFS\Foo 5.1\Trunk\Foo.Synchronization.Plugin\Synchronizer.cs:line 91
InnerException:
Общий метод
public static TResult ExecuteRequest<TChannel, TResult>(
this ChannelFactory<TChannel> factory,
Func<TChannel, TResult> readDelegate)
{
if (factory == null || readDelegate == null)
{
return default(TResult);
}
TChannel channel = factory.CreateChannel();
#if DEBUG
// Changes the timeout to 10 minutes so you can step through server
// code if you need to without getting a timeout error.
((IClientChannel)channel).OperationTimeout = TimeSpan.FromMinutes(10);
#endif
TResult result;
try
{
result = readDelegate(channel);
}
finally
{
var client = (IClientChannel)channel;
if (client.State == CommunicationState.Faulted)
{
client.Abort();
}
else
{
client.Close();
}
client.DisposeSafe();
}
return result;
}