9
给定的合同,如:RESTful WCF服务可以在JSON(P)和XML中都响应,仍然可以用作SOAP Web服务?
[ServiceContract] public interface IService
{
[OperationContract]
[WebGet(UriTemplate = "GetData/{id}.{format}")]
ResponseData GetData(string id, string format);
}
是否存在时所要求的方式去使用JSON响应服务:当作为/GetData/1234.xml并请 /GetData/1234.json,XML仍然可以作为一个适当的SOAP服务在其他网址,与强类型WSDL合同?
使用Stream作为GetData的返回值是行不通的,就像它满足前两个要求一样,wcf不能创建完整的wsdl规范,因为它不知道生成的Stream的内容是什么。
请参阅[codemeit](http://www.codemeit.com/wcf/wcf-restful-pox-json-and-soap-coexist.html)中的[WCF RESTful POX,JSON和SOAP共存] //stackoverflow.com/users/11413/codemeit)。 – 2009-03-04 07:20:34