Error using WCF Load Test with known types

Oct 20, 2010 at 8:02 PM

Hi,

 

We're getting an error when running WCF Load Test 3.0.10.0614:

    Element '[base]' contains data from a type that maps to the name '[derived]'. The deserializer has no knowledge of any type that maps to this name.

This is an excerpt - I've included the full message below. We do have the derived type registered as a known type, but it's still failing.

 

We're using Davy Brion's Agatha framework (http://code.google.com/p/agatha-rrsl/) on top of WCF 4. Agatha defines the IWcfRequestProcessor service contract, which includes the following method:

    Response[] Process(Request[] requests);

The Request and Response types are defined by Agatha. We implement our own derived request and response messages in our own assembly. 

Agatha adds a ServiceKnownType attribute on the Process() interface method, which points to Agatha's known type provider. The known type provider registers our custom derived requests and responses as known types.

I can see our derived types in the WSDL when I go to OurService.svc?wsdl. I can also successfully add a service reference and call the service from a client that does not use Agatha. The generated service reference code includes all the derived known types. I can generate a proxy successfully via "svcutil" as well. I'm only getting an error when using WCF Load Test.

 

When using either the wizard or the command-line WcfUnit.exe, we get the following error:

"Element 'http://schemas.datacontract.org/2004/07/Agatha.Common:Request' contains data from a type that maps to the name 'http://schemas.datacontract.org/2004/07/IMS.Shared:GetBrokerAccountsRequest'. The deserializer has no knowledge of any type that maps to this name. Consider using a DataContractResolver or add the type corresponding to 'GetBrokerAccountsRequest' to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding it to the list of known types passed to DataContractSerializer."

As I mentioned, we aren't using the KnownTypeAttribute, but Agatha is accomplishing the same thing via the ServiceKnownTypeAttribute on the contract method.

When I run WCF Load Test, it asks me to select assemblies. I include the Agatha.Common assembly which contains IWcfRequestProcessor, Request, and Response; and I include our own assembly containing the derived request and response types.

 

Does anyone have any suggestions for troubleshooting this issue?

Thanks for your help,
Richard

Oct 21, 2010 at 5:48 AM

I'm still looking into this... here are some more details.

 

Here is the stack trace when running the following command line:

WcfUnit.exe Foo Web_messages.svclog foo.config

WCF Load Test Generator Version 3.0.0.0Parsed message with action http://tempuri.org/IWcfRequestProcessor/ProcessRequests [OK]
Unhandled Exception: System.Runtime.Serialization.SerializationException: Element 'http://schemas.datacontract.org/2004/07/Agatha.Common:Request' contains data from a type that maps to the name 'http://schemas.datacontract.org/2004/07/IMS.Shared:GetOutstandingOrdersRequest'. The deserializer has no knowledge of any type that maps to this name. Consider using a DataContractResolver or add the type corresponding to 'GetOutstandingOrdersRequest' to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding it to the list of known types passed to DataContractSerializer.   at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator reader, String name, String ns, Type declaredType, DataContract& dataContract)   at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator xmlReader, Int32 id, RuntimeTypeHandle declaredTypeHandle, String name, String ns)   at ReadArrayOfRequestFromXml(XmlReaderDelegator , XmlObjectSerializerReadContext , XmlDictionaryString , XmlDictionaryString , CollectionDataContract )   at System.Runtime.Serialization.CollectionDataContract.ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context)   at System.Runtime.Serialization.XmlObjectSerializerReadContext.ReadDataContractValue(DataContract dataContract, XmlReaderDelegator reader)   at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator reader, String name, String ns, Type declaredType, DataContract& dataContract)   at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator xmlReader, Type declaredType, DataContract dataContract, String name, String ns)   at System.Runtime.Serialization.DataContractSerializer.InternalReadObject(XmlReaderDelegator xmlReader, Boolean verifyObjectName, DataContractResolver dataContractResolver)   at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)   at System.Runtime.Serialization.DataContractSerializer.ReadObject(XmlDictionaryReader reader, Boolean verifyObjectName)   at Microsoft.WcfUnit.Library.Deserializer.DeserializeDataContractInputParameters(MessageBuffer messageBuffer, String proxyNamespace, ParameterInfo[] parameters, IList`1 serviceKnownTypes)   at Microsoft.WcfUnit.Library.Deserializer.DeserializeInputParameters(MessageBuffer messageBuffer, MethodBase contractMethod)   at Microsoft.WcfUnit.Library.TraceFileProcessor.ProcessTraceFile(String scenarioName, String traceFileName, Stream timedCommentsFile, WcfUnitConfiguration configuration, String mainFileName, String stubFileName)   at Microsoft.WcfUnit.Library.TraceFileProcessor.ProcessTraceFile(String scenarioName, String traceFile, Stream timedCommentsFile, WcfUnitConfiguration configuration)   at Microsoft.WcfUnit.Program.Main(String[] args)

 

Here's my foo.config file:

<?xml version='1.0' encoding='utf-8' ?>
<WcfUnitConfiguration xmlns='http://microsoft.com/wcfunit' testMethodMode='ScenarioMethodOnly' operationTimerMode='IncludeOperationTimers' clientTrace='false' serviceTrace='true'>  
  <assembly fileName="C:\svn\IMS\src\Server.Service\bin\Agatha.Common.dll"/>  
  <assembly fileName="C:\svn\IMS\src\Server.Service\bin\IMS.Server.Shared.dll"/>  
  <soapActions soapActionMode='Include' />
</WcfUnitConfiguration>

 

 

I also had to add a WcfUnit.exe.config file, with '<supportedRuntime version="v4.0.30319" />'.

 

Thanks,
Richard

 

 

Oct 21, 2010 at 8:16 AM

I've finally found the issue :). The problem is that Microsoft.WcfUnit.Library.Deserializer.GetServiceKnownTypes() only checks for the [ServiceKnownType] attribute on the contract interface. But Agatha puts the attribute on the individual operation methods, not at the interface level. So WCF Load Test isn't picking up the known types.

Agatha is open-source, so if necessary I can patch it to put the attribute on the interface instead. It would be great if WCF Load Test could also check for the attribute on the method though.

Thanks,
Richard

 

Coordinator
Oct 21, 2010 at 8:22 AM

Thank you for your analysis. I have added this to the bug list, but I can't really say when it will get fixed.

Rob