Search code examples
wcfserializationmsmqdatacontractserializersystem.messaging

Is it possible to return System.Messaging.Message in a serviceContract?


Hej, I am using the httpBinding / netTcpBinding in my WCF service, I am trying to replace some .Net remoting code with WCF. This was my first test when translating the methods of my .Net remoting to a WCF service contract. I translated my methods literally the old code uses System.Messaging.Message as return type.

My service contract:

<OperationContract(Name:="ReceiveWithTimeOut")>
  <TransactionFlow(TransactionFlowOption.Allowed)>
  Function Receive(ByVal TimeOut As TimeSpan) As System.Messaging.Message

Everyting builds, service goes up but when I surf to my service i got the following error:

System.InvalidOperationException: An exception was thrown in a call to a WSDL export extension: System.ServiceModel.Description.DataContractSerializerOperationBehavior contract: http://..../ServiceContracts/2012/V1:IReaderContract ----> System.Runtime.Serialization.InvalidDataContractException: Type 'System.Messaging.MessageQueue' cannot be serialized.

Is there any way to return a System.Messaging.Message?

Thank you very much.

Kind regards.

Jonathan


Solution

  • I created a own datacontract and let the client / server create MSMQ messages with the properties of that datacontract.