Bir WCF hizmetinde kullanılan bir yöntemi açıklayan bir ServiceContract var. Yöntem, bir UriTemplate ve ResponseFormat tanımlayan bir WebGet özniteliğine sahiptir.WCF OperationContract yönteminin WebGet özniteliği birden çok ResponseFormat türüne sahip olabilir mi?
Tek bir yöntemi yeniden kullanmak ve farklı UriTemplates ve farklı ResponseFormats ile birden çok WebGet özniteliğine sahip olmak istiyorum. Temelde, XML türüne karşılık JSON gibi dönüş türlerini ayırt etmek için birden fazla yönteme sahip olmaktan kaçınmayı umuyorum. Şimdiye kadar gördüğüm tüm örneklerde, her WebGet özniteliği için farklı bir yöntem oluşturmam gerekiyor.
[ServiceContract]
public interface ICatalogService
{
[OperationContract]
[WebGet(UriTemplate = "product/{id}/details?format=xml", ResponseFormat = WebMessageFormat.Xml)]
[WebGet(UriTemplate = "product/{id}/details?format=json", ResponseFormat = WebMessageFormat.Json)]
Product GetProduct(string id);
}
yüzden bunu başarmak için bir yol var mı: İşte böyle xml ve json dönüş türleri her ikisi için içinCategoryConfigurationnesne kullanmak istiyorum Yukarıdaki örneğe
[ServiceContract]
public interface ICatalogService
{
[OperationContract]
[WebGet(UriTemplate = "product/{id}/details?format=xml", ResponseFormat = WebMessageFormat.Xml)]
Product GetProduct(string id);
[OperationContract]
[WebGet(UriTemplate = "product/{id}/details?format=json", ResponseFormat = WebMessageFormat.Json)]
Product GetJsonProduct(string id);
}
OperationContract örneği verilmiştir Farklı ResponseFormat'ları döndürmek için farklı yöntemler yazmam mümkün değil mi?
Teşekkürler!