当我尝试使用通用消息处理程序时,如果我使用我自己的类型(例如 text/x-json),我会在接受或内容类型为 html/xml/json 时遇到错误,一切都按预期工作,消息被发送到我的处理程序和流将数据返回给 webclient。我已经使用调试器逐步完成了此操作,并且我的代码成功创建了消息,但是服务总线绑定中的某些内容阻塞并导致服务器不响应。是否需要更改设置以允许 application/json 并使服务总线发送原始数据而不是尝试重新序列化它?
[WebGet( UriTemplate = "*" )]
[OperationContract( AsyncPattern = true )]
public IAsyncResult BeginGet( AsyncCallback callback, object state )
{
var context = WebOperationContext.Current;
return DispatchToHttpServer( context.IncomingRequest, null, context.OutgoingResponse, _config.BufferRequestContent, callback, state );
}
public Message EndGet( IAsyncResult ar )
{
var t = ar as Task<Stream>;
var stream = t.Result;
return StreamMessageHelper.CreateMessage( MessageVersion.None, "GETRESPONSE", stream ?? new MemoryStream() );
}