Hi guys I have the following code:
public virtual void Initialise()
{
this.AddHeader("SystemContext", this.UserSettings.SystemContext);
}
public virtual void AddHeader(string key, object value)
{
var customHeader = MessageHeader.CreateHeader(key, this.SystemSettings.SystemServiceNamespace, value);
OperationContext.Current.OutgoingMessageHeaders.Add(customHeader);
}
When I try and execute the server after I have run the above code, I get the following error:
Type 'ACSIS.Core.Common.Configuration.UserAcountDetials' with data contract name 'UserAcountDetials:http://schemas.datacontract.org/2004/07/ACSIS.Core.Common.Configuration' is not expected. Add any types not known statically to the list of known types - for example, by using the
KnownTypeAttribute
attribute or by adding them to the list of known types passed to DataContractSerializer.
Now UserSettings
describes SystemContext
as being of type IDictionary
. I understand that WCF can't magically create objects out of thin air or what ever, so I need to help it out a little.
Is there some way that I can pass the runtime type of object over the wire as well and have it converted back into that type on the other side. I am not using WCF for java to .net SOA stuff or anything like that, I know the concrete type will be on the other side of the wire.
If WCF doesn't really support this (there must be some way though), is there a way I could serialize the data into a binary format, attach the binary to the header and handle serialization myself, using the type information I pass across.