WCF Web HTTP Service Help Page만들기 (URI, Method-GET/POST등)
.net Framework 4.6.1에서 WCF WEB HTTP를 위한 Help page를 자동으로 생성됩니다.
예를 들어 다음과 같이 "/help"을 붙이면 다음과 같이 나타납니다.
(예: http://localhost:8000/Customers/Help )
Using the WCF Web HTTP Help Page
The WCF WEB HTTP Help page displays a short description for each operation provided that you specify one using the DescriptionAttribute. This attribute takes a string that contains a short description of the operation it is applied to. For example, the following code shows how to use the DescriptionAttribute to provide a short description.
[OperationContract] [WebGet(UriTemplate="/template1", BodyStyle = WebMessageBodyStyle.Bare)] [Description("Description for GET /template1")] SyndicationFeedFormatter GetTemplate1(); |
To turn on the WCF WEB HTTP Help page, you must add an endpoint behavior to your service's endpoints. This can be done in configuration or code. To enable the WCF WEB HTTP Help age in configuration, add an endpoint behavior with a <webHttp>
element, set enableHelp
to true
, and add an endpoint and configure it to use the endpoint behavior. The following configuration code shows how to do this.
<endpointBehaviors> <behavior name="RESTEndpointBehavior"> <webHttp enableHelp="true"/> </behavior> </endpointBehaviors> <!-- ... --> <services> <service behaviorConfiguration="RESTWebServiceBehavior" name="RESTWebService"> <endpoint address="" kind="webHttpEndpoint" behaviorConfiguration="RESTEndpointBehavior" contract="IHello" />
<!-- ... --> </service> </services> |
To enable the WCF Web HTTP Help page in code, add a service endpoint and add a WebHttpBehavior to the endpoint setting EnableHelp
to true
. The following code shows how to do this.
using (WebServiceHost host = new WebServiceHost(typeof(Service), new Uri("http://localhost:8000/Customers"))) { host.AddServiceEndpoint(typeof(ICustomerCollection), new WebHttpBinding(), ""); host.Description.Endpoints[0].Behaviors.Add(new WebHttpBehavior { EnableHelp = true }); // ... } |
The help page is XHTML based with mark-up that identifies the different parts of the page. This enables clients to programmatically access the page using XElement or other XLinq APIs.
출처: https://docs.microsoft.com/en-us/dotnet/framework/wcf/feature-details/wcf-web-http-service-help-page