I'm currently building my own WCF Encoder that will parse my message. I want to dynamically change the content type that is assigned when I'm sending a reply but I can't get my head around where he is looking for it.
Is he using the CustomTextEncoder.ContentType or the content type of the innerencoder? How can I force him to send the response as "text/xml" or "application/soap+xml"?
Thank you in advance.
EDIT - Just to clarify that I need to the decision in the WriteMessage-method of my custom encoder. I'm using a string property that holds the requested content type but he's not doing it correctly.
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";
...
}
}
Unfortunately when I send my message he's still assigning the default value of my encoder...
It seems like can't change the content type of an inbound request, my problem was fixed by using a Message Inspector where I assign the content type that I want. (This link helped me)
Good to know - The ACKs from the encoder are not passing through the Message Inspector so it uses the ContentType-property.