我正在尝试使用自定义绑定编写服务,该自定义绑定使用webMessageEncoding和httpsTransport websocket。我使用了自定义消息格式化程序和自定义类型映射器来帮助发送消息。
当我发送邮件时,该邮件看起来与我期望的完全一样,但另一方面,它收到的是空邮件,我不知道为什么。我在客户端和服务器上都打开了消息日志记录,以检查消息。
从客户端发送的消息:(MessageType = System.ServiceModel.Channels.BodyWriterMessage)
<MessageLogTraceRecord>
<HttpRequest xmlns="http://schemas.microsoft.com/2004/06/ServiceModel/Management/MessageTrace">
<Method>POST</Method>
<QueryString></QueryString>
<WebHeaders>
<VsDebuggerCausalityData>uIDPo1syfvtgrZtHuD/oB7GQ3FEAAAAAvIX1PeSPTEGzLNjM5HGBK5EJkUJMfDtPq7d73X4fCgkACQAA</VsDebuggerCausalityData>
</WebHeaders>
</HttpRequest>
<Subscribe xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="L3.Airport.CV2">
<FlightId>c66e0a88-06c8-4c36-99b5-79ca5453d96a</FlightId>
</Subscribe>
</MessageLogTraceRecord>
服务收到的消息:(MessageType = System.ServiceModel.Channels.ByteStreamMessage + InternalByteStreamMessage)
<MessageLogTraceRecord>
<Binary xmlns=""></Binary>
</MessageLogTraceRecord>
Web.config绑定
<customBinding>
<binding name="WebSocketBinding_Duplex">
<byteStreamMessageEncoding />
<httpsTransport>
<webSocketSettings transportUsage="Always" />
</httpsTransport>
</binding>
<binding name="WebSocketBinding_Airport">
<webMessageEncoding webContentTypeMapperType=
"L3.Cargo.ClearView.Common.Utilities.SessionBehaviours.RawContentTypeMapper, L3.Cargo.Clearview.Common.Utilities,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
<httpsTransport>
<webSocketSettings transportUsage="Always" />
</httpsTransport>
</binding>
</customBinding>
Web.config端点:
<endpoint address="Duplex" binding="customBinding" bindingConfiguration="WebSocketBinding_Airport" contract="L3.Airport.Common.Interfaces.AirportServiceInterface.IAirportServiceDuplex"></endpoint>
App.config绑定:
<customBinding>
<binding name="anonymousWsBinding">
<byteStreamMessageEncoding />
<httpsTransport>
<webSocketSettings transportUsage="Always" />
</httpsTransport>
</binding>
<binding name="WebSocketBinding_Airport">
<webMessageEncoding webContentTypeMapperType="L3.Cargo.ClearView.Common.Utilities.SessionBehaviours.RawContentTypeMapper, L3.Cargo.ClearView.Common.Utilities, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null" />
<httpsTransport>
<webSocketSettings transportUsage="Always" />
</httpsTransport>
</binding>
</customBinding>
App.config端点:
我真的不确定这是怎么发生的。为什么只收到空消息? WCF如何确定传入消息的格式?