我已经创建了一个WCF Web服务,它将适应多种类型的请求(PUT/DELETE/POST/JSON/POX/SOAP)。为此,我针对每个请求风格进行了单独的操作,并使用定义请求类型的属性。因此,如果我有一个名为“WordInfo()”的操作,我会有“WordInfo_POST”,“WordInfo_GETXML()”,“WordInfo_GETJSON()”等。如何将GET/PUT/POST请求指向不同的WCF方法,而不显示这些方法?
问题是,我不希望显示这些额外方法在用户使用客户端应用程序中的WSDL时给用户。换句话说,我不希望他们在intellisense中出现。下面是我在谈论的一个例子:
[ServiceContract]
interface IWVLibrary
{
[OperationContract]
[WebGet(UriTemplate = "WordInfo/{Data}/{ApiKey}?format=xml", ResponseFormat = WebMessageFormat.Xml)]
[return: MessageParameter(Name = "WordInfo")]
WordInfoResult WordInfo_GETXML(string data, string ApiKey);
[OperationContract]
[WebGet(UriTemplate = "WordInfo/{Data}/{ApiKey}?format=json", ResponseFormat = WebMessageFormat.Json)]
[return: MessageParameter(Name = "WordInfo")]
WordInfoResult WordInfo_GETJSON(string Data, string ApiKey);
[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "", BodyStyle = WebMessageBodyStyle.Wrapped, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
[return: MessageParameter(Name = "WordInfo")]
WordInfoResult WordInfo_POST(string Data, string ApiKey);
[OperationContract]
[WebInvoke(Method = "PUT", UriTemplate = "", BodyStyle = WebMessageBodyStyle.Wrapped, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
[return: MessageParameter(Name = "WordInfo")]
WordInfoResult WordInfo_PUT(string Name, string ApiKey);
[OperationContract]
[WebInvoke(Method = "DELETE", UriTemplate = "WordInfo/{Data}/{ApiKey}", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)]
[return: MessageParameter(Name = "WordInfo")]
WordInfoResult WordInfo_DELETE(string Data, string ApiKey);
[OperationContract]
[WebInvoke(BodyStyle = WebMessageBodyStyle.Wrapped)]
WordInfoResult WordInfo(string Data, string ApiKey);
}
但在这个例子中,我只会想“WORDINFO()”公开曝光。
我已经尝试过让操作是私人的,但它要么不会编译,要么不会再接受请求的类型。
谢谢!