Extracting Content Types
What is the content type of the message returned by a service?
The idea of a content MIME type is very popular in HTTP programming, both for communicating the format of the data and the text encoding inside that format. However, content types are not generally used for SOAP processing. If you look at the SOAP specifications, you'll notice that there are fixed content types for describing the message. The message format is SOAP after all. SOAP messaging also generally has a limited choice for text encodings. The application message format inside the SOAP format is more likely what you care about. That information is transmitted out-of-band as part of the service metadata.
What this means is that there's no standard object model in WCF for accessing the content type of a message, even when you're not really doing SOAP programming. That's a legacy of being primarily designed for SOAP. There's not a promise here, but there is one spot where the content type can be optionally offered up when supported. If you take your message, one of the message properties is the message encoder. Stamping messages with the message encoder is optional, but if that has been done in the pipeline, then you can query the message encoder for its content type. Note that this isn't the same as the message content type. There's only one message encoder for many messages, so what you're seeing is the default content type for the message rather than the specific content type of the message that was received.
Next time: Channel Writing Checklist (Required)
Comments
- Anonymous
March 09, 2007
I was looking through the archives the other day and found that the original article on channel shapes