Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何将GET/PUT/POST请求定向到不同的WCF方法,而不显示这些方法?_C#_Json_Wcf_Http_Rest - Fatal编程技术网

C# 如何将GET/PUT/POST请求定向到不同的WCF方法,而不显示这些方法?

C# 如何将GET/PUT/POST请求定向到不同的WCF方法,而不显示这些方法?,c#,json,wcf,http,rest,C#,Json,Wcf,Http,Rest,我创建了一个WCF Web服务,它将容纳多种类型的请求PUT/DELETE/POST/JSON/POX/SOAP。为此,我对每个请求风格进行了单独的操作,使用定义请求类型的属性。因此,如果我有一个名为WordInfo的操作,我会有WordInfo_POST、WordInfo_GETXML、WordInfo_GETJSON等 问题是,当用户在其客户机应用程序中使用WSDL时,我不希望向用户显示这些附加方法。换句话说,我不希望他们出现在intellisense中。下面是我所说的一个例子: [Serv

我创建了一个WCF Web服务,它将容纳多种类型的请求PUT/DELETE/POST/JSON/POX/SOAP。为此,我对每个请求风格进行了单独的操作,使用定义请求类型的属性。因此,如果我有一个名为WordInfo的操作,我会有WordInfo_POST、WordInfo_GETXML、WordInfo_GETJSON等

问题是,当用户在其客户机应用程序中使用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

我曾尝试将操作设置为私有,但它要么无法编译,要么不再接受请求类型


谢谢

我认为您应该使用,它适合您的需要。

REST服务没有WSDL

那么你想要达到什么目标呢?无论如何,用户不会看到任何方法,因为没有WSDL

是的,对于REST服务存在的“帮助”页面,您可以禁用standart帮助页面,并创建自己的,并且只描述您想要公开的方法

或者,若您不希望客户端使用某些方法,只需不公开它并删除它们上的WebGet、WebInvoke属性即可