I have a SOAP service that's been running for a little over a month now. Over the past two weeks we've had situations where the service will randomly start to generate exceptions. Each time, they seem to be related to the export extension, and the error is always along the following lines:
An exception was thrown in a call to a WSDL export extension: System.ServiceModel.Description.DataContractSerializerOperationBehavior
With "System.ArgumentException: The named node is from a different document context." seeming to be the root cause each time.
What's bugging me is that this service hasn't changed in a month and a half, so I'm confused how suddenly we'd be getting the argument errors all of a sudden. Is this more indicative of an underlying issue (memory leak or similar)?
I have very limited access to the machine this is running on, but can try and get any supporting information as needed. Here's the full exception the wsdl is coming back with:
An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is:
System.InvalidOperationException: An exception was thrown in a call to a WSDL export extension: System.ServiceModel.Description.DataContractSerializerOperationBehavior
Endpoint: [endpoint name here... hidden for security] ----> System.ArgumentException: The named node is from a different document context.
at System.Xml.XmlAttributeCollection.Append(XmlAttribute node)
at System.ServiceModel.Description.SoapHelper.CreateSoapFaultBinding(String name, WsdlEndpointConversionContext endpointContext, FaultBinding wsdlFaultBinding, Boolean isEncoded)
at System.ServiceModel.Description.MessageContractExporter.MessageBindingExporter.ExportMessageBinding(OperationDescription operation, Type messageContractExporterType)
at System.ServiceModel.Description.WsdlExporter.CallExtension(WsdlEndpointConversionContext endpointContext, IWsdlExportExtension extension)
--- End of inner ExceptionDetail stack trace ---
at System.ServiceModel.Description.ServiceMetadataBehavior.MetadataExtensionInitializer.GenerateMetadata()
at System.ServiceModel.Description.ServiceMetadataExtension.EnsureInitialized()
at System.ServiceModel.Description.ServiceMetadataExtension.HttpGetImpl.InitializationData.InitializeFrom(ServiceMetadataExtension extension)
at System.ServiceModel.Description.ServiceMetadataExtension.HttpGetImpl.GetInitData()
at System.ServiceModel.Description.ServiceMetadataExtension.HttpGetImpl.TryHandleMetadataRequest(Message httpGetRequest, String[] queries, Message& replyMessage)
at System.ServiceModel.Description.ServiceMetadataExtension.HttpGetImpl.ProcessHttpRequest(Message httpGetRequest)
at SyncInvokeGet(Object , Object[] , Object[] )
at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
EDIT: I wanted to clarify that the service doesn't always hit this exception. Sometimes the wsdl comes back fine, other times it throws this exception (I'd say currently it's a 50/50 shot of getting a successful return). I can't make heads or tails as to why. My initial thought goes to an environment problem, but if that's the case, I don't have a clue where to point the hosting team to look.
EDIT 2: Since asking the initial inquiry I've found out that the client has put the services on multiple servers and is using a load balancer, which, I believe, accounts for the random responses we're getting. I've advised them how to proceed in at least isolating the problem and will go from there.