How do I view my Swagger docs when using SwaggerWcf?

1.3k Views Asked by At

I'm trying to use swaggerwcf to add Swagger to my WCF REST API.

I've followed the instructions, but I don't know what URL to use to view my Swagger documentation. I've tried:

http://myservername/api-docs

http://myservername/api-docs/index.html

http://myservername/api-docs/swagger.json

These all result in "Request Error", "The server encountered an error processing the request. Please see the service help page for constructing valid requests to the service."

2

There are 2 best solutions below

1
Ackelry Xu On

It dependents on what code you have written in global.asax.

For example, my code in global.asax is

  protected void Application_Start(object sender, EventArgs e)
    {
        RouteTable.Routes.Add(new ServiceRoute("RegistrationService/api-docs", new WebServiceHostFactory(), typeof(SwaggerWcfEndpoint)));
    }

Then I should visit http://localhost:62193/RegistrationService/api-docs (http://localhost:62193 is my root path).

Also, please ensure you have configured web.xml.

  <service name="SwaggerWcf.SwaggerWcfEndpoint">
    <endpoint address="" binding="webHttpBinding" contract="SwaggerWcf.ISwaggerWcfEndpoint"></endpoint>
  </service>

<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
  multipleSiteBindingsEnabled="true" />
</system.serviceModel>
 <system.webServer>


<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>

Then if you input http://localhost:62193/RegistrationService/api-docs/, it will redirect you to http://localhost:62193/RegistrationService/api-docs/index.html?url=/RegistrationService/api-docs/swagger.json#!/Books/Service_BookStore_ReadBooks

Below is the result. enter image description here

0
soumya cb On

Still its not displaying method info on swagger