是否可以在serviceContract中返回System.Messaging.Message?

时间:2012-01-03 15:48:52

标签: wcf serialization msmq datacontractserializer system.messaging

HeJ小鼠, 我在我的WCF服务中使用httpBinding / netTcpBinding,我试图用WCF替换一些.Net远程代码。这是我将.Net远程处理方法转换为WCF服务合同时的第一次测试。我从字面上翻译了我的方法旧代码使用System.Messaging.Message作为返回类型。

我的服务合同:

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

每个构建,服务都会上升,但当我浏览我的服务时,我收到以下错误:

  

System.InvalidOperationException:调用时抛出异常   WSDL导出扩展:   System.ServiceModel.Description.DataContractSerializerOperationBehavior   合同:http://..../ServiceContracts/2012/V1:IReaderContract ----&gt;   System.Runtime.Serialization.InvalidDataContractException:Type   “System.Messaging.MessageQueue”无法序列化。

有没有办法返回System.Messaging.Message?

非常感谢你。

亲切的问候。

乔纳森

1 个答案:

答案 0 :(得分:0)

我创建了一个自己的datacontract,让客户端/服务器创建具有该datacontract属性的MSMQ消息。