Hi,
I have a WCF service which I would like to product XML and JSON depending on the URI template. So in my service contract I have methods like the following
[ServiceContract]
public interface MultiFormatContract
{
[OperationContract]
[WebGet(UriTemplate="/json/data", ResponseFormat = WebMessageFormat.Json)]
[JSONPBehavior(callback = "callback")]
public MySerializableObject GetJSONData()
[OperationContract]
[WebGet(UriTemplate = "/xml/data", ResponseFormat=WebMessageFormat.Xml)]
public MySerializableObject GetXMLData()
}
I have a requirement to support JSONP and have used the Microsoft REST sample to support this (following this http://jasonkelly.net/archive/2009/02/24/using-jquery-amp-jsonp-for-cross-domain-ajax-with-wcf-services.aspx). However this has meant that I had to add a custom binding:
<customBinding>
<binding name="jsonpBinding">
<jsonpMessageEncoding/>
<httpTransport manualAddressing="true"/>
</binding>
</customBinding>
This means WCF is no longer using the textMessageEncoding and even though JSONPEncoder overrides the text encoder. My endpoints can no longer produce Xml.
I don't want to lock consumers to JSON and I'd like to be able to browse to my Xml endpoint to see the Xml for debugging etc.
Any ideas on how I can have both?