Mapping WCF Web Service Operations

So, I created a WCF service application and hosted it on IIS7. He currently has several helloworld test methods. When I launch it in my browser, I get this screen: enter image description here

Now the service itself works fine, but how can I display the following operations: enter image description here

Thanks to marc_s for the link: http://www.dotnetcurry.com/ShowArticle.aspx?ID=399 that I followed, so my web configuration is now configured like this:

<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.web> <compilation debug="true" targetFramework="4.0" /> </system.web> <system.serviceModel> <services> <service name="WcfServer.Service1"> <endpoint address="" binding="webHttpBinding" contract="WcfServer.IService1" behaviorConfiguration="HelpBehaviour" /> </service> </services> <behaviors> <serviceBehaviors> <behavior> <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --> <serviceMetadata httpGetEnabled="true" /> <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information --> <serviceDebug includeExceptionDetailInFaults="false" /> </behavior> </serviceBehaviors> <endpointBehaviors> <behavior name="AjaxBehavior"> <enableWebScript /> </behavior> <behavior name="HelpBehaviour"> <webHttp helpEnabled="true"/> </behavior> </endpointBehaviors> </behaviors> </system.serviceModel> <system.webServer> <modules runAllManagedModulesForAllRequests="true" /> <directoryBrowse enabled="true" showFlags="Date, Time, Size, Extension" /> </system.webServer> </configuration> 

However, this only works locally. When I publish on my IIS7 server, I get a 404 error page when I click the help link. Does anyone know why this happened, or did it reach him?

(The last bit was resolved by running: aspnet_regiis.exe -iru )

+4
source share
1 answer

If you have a WCF service with SOAP binding, you are unfortunately unlucky: there is no way in WCF to publish a listing similar to ASMX with all services.

With REST binding ( webHttpBinding ) and .NET 4.0, you can create an automatic help page that lists URI patterns, supported HTTP methods, etc. You can also customize this page to a certain extent.

To create an automatic help page, you need to define (and link) the behavior of the endpoint:

 <behaviors> <endpointBehaviors> <behavior name="HelpBehavior"> <webHttp helpEnabled="true" /> </behavior> </endpointBehaviors> </behaviors> 

Then specify this behavior from the webHttpBinding , and you webHttpBinding done.

Read all about it:

+9
source

Source: https://habr.com/ru/post/1338247/


All Articles