for some reason I am asked to see if it possible to override the /help method of a service to return custom data instead. Currently I have a calling url like this one
http://{myDomain}/CRM/Customers.svc/json/help
Which returns all methods available
I tried something like this in my serviceContract, but I can't access to my method, is it possible ?
[WebInvoke(Method = "GET", UriTemplate = "/help", RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json)]
void GetInformations();
Thanks
By default in web.config help page is enabled in the web http endpoint. To override it you could set as false, then your override method will be triggered.
<webHttpEndpoint>
<!-- TIP: Enable automatic XML/JSON support -->
<!-- TIP: Enable service help page -->
<standardEndpoint automaticFormatSelectionEnabled="true" helpEnabled="false"/>
</webHttpEndpoint>
Thanks to @Balaji I dig a bit more and was able to make it work in a slightly different way. I applied a custom behaviorConfiguration to my service and in it I disabled the help, see below
<system.serviceModel>
<services>
<service behaviorConfiguration="ServiceBehavior" name="{myDomain}.CRM.Customers">
<endpoint address="json" binding="webHttpBinding" behaviorConfiguration="JsonBehavior" bindingConfiguration="" contract="{contract}"/>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="JsonBehavior">
<webHttp helpEnabled="false"/>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.