我目前正在构建自己的WCF编码器,以解析我的消息。我想动态更改发送回复时分配的内容类型,但是我无法理解他正在寻找的内容。
他使用的是CustomTextEncoder.ContentType还是innerencoder的内容类型?如何强制他将响应以“ text / xml”或“ application / soap + xml”的形式发送?
先感谢您。
编辑-只是为了阐明我需要对我的自定义编码器的WriteMessage方法中的决定。我正在使用一个字符串属性,其中包含请求的内容类型,但是他没有正确执行。
public class MyEncoder : MessageEncoder
{
private string _contentType = "application/soap+xml";
public override string ContentType
{
get
{
return _contentType;
}
}
public override ArraySegment<byte> WriteMessage(Message message, int maxMessageSize, BufferManager bufferManager, int messageOffset)
{
...
if (_MY_CONDITION_HERE_)
{
_contentType = "multipart/related";
}
else
_contentType = "application/soap+xml";
...
}
}
不幸的是,当我发送消息时,他仍在分配编码器的默认值...
似乎无法更改入站请求的内容类型,我的问题已通过使用Message Inspector进行了修复,在其中分配了所需的内容类型。(此链接对我有帮助)
提提您-来自编码器的ACK没有通过消息检查器,因此它使用ContentType属性。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句