我创建了一个 WCF Web 服务,它将容纳多种类型的请求 (PUT/DELETE/POST/JSON/POX/SOAP)。为此,我为每个请求风格进行了单独的操作,并使用定义请求类型的属性。因此,如果我有一个名为“WordInfo()”的操作,我将有“WordInfo_POST”、“WordInfo_GETXML()”、“WordInfo_GETJSON()”等。
问题是当用户在其客户端应用程序中使用 WSDL 时,我不希望向用户显示这些附加方法。换句话说,我不希望它们出现在智能感知中。这是我正在谈论的一个例子:
[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()”公开。
我尝试将操作设为私有,但它要么无法编译,要么不再接受请求的类型。
谢谢!