Comments (6)
Please try to fix first the issue using WebServiceHostFactory, just to make sure everything is setup correctly, after that we'll try to move to ServiceHostFactory (never tried, and didn't check if there are limitations)
404 should be something missing in the configuration
If you want to use http://localhost/AbcWebService/api-docs
You have to configure the route accordingly:
RouteTable.Routes.Add(new ServiceRoute("AbcWebService/api-docs", new WebServiceHostFactory(), typeof(SwaggerWcfEndpoint)));
With this change are you able to open the page?
from swaggerwcf.
Thanks for the response. I will work some more on trying to get WebServiceHostFactory
to work.
I believe that the fact that I have AbcWebService
set up as a virtual path under IIS means that AbcWebService
is expected in the URL, and it won't resolve properly without it.
I will re-verify, but I found that:
- if I don't have
AbcWebService
in the URL, it doesn't even recognize the code I'm trying to reach (e.g. The Physical Path listed on the 404 page doesn't resolve to my local code location: C:\inetpub\wwwroot\api-docs) - if I do have
AbcWebService
in the URL, then at least it recognizes what service I'm trying to reach (Physical Path on that 404 page: C:\Git\Abc\AbcWebService\api-docs)
Specifically to address your question/suggestion:
Using:
RouteTable.Routes.Add(new ServiceRoute("AbcWebService/api-docs", new WebServiceHostFactory(), typeof(SwaggerWcfEndpoint)));
And navigating to http://localhost/AbcWebService/api-docs
gives me a 404 with a physical path of C:\Git\Abc\AbcWebService\api-docs
So no, I'm still unable to open the page :(
But thanks for reading, and your suggestions. Hopefully I'll have some progress to report tomorrow.
from swaggerwcf.
Update:
I don't believe it's a routing issue anymore. I have the following two entries in Global.asax
:
RouteTable.Routes.Add(new ServiceRoute("v1", new WebServiceHostFactory(), typeof(AbcWCF))); RouteTable.Routes.Add(new ServiceRoute("api-docs", new WebServiceHostFactory(), typeof(SwaggerWcfEndpoint)));
When I navigate to http://localhost/AbcWebService/v1/Customer
I get an authentication prompt, which is as expected for the IAbcWcf.svc/Customer
GET endpoint. But, when I navigate to http://localhost/AbcWebService/api-docs
, I'm still getting a 404:
Server Error in '/AbcWebService' Application.
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested URL: /AbcWebService/api-docs
So I still can't figure out why one route would work, but the SwaggerWCF would not. If you have any further suggestions, I'd appreciate it. Otherwise, I'm trying to troubleshoot by creating my own endpoint that invokes SwaggerWcf.SwaggerWcfEndpoint.Configure
and related methods.
from swaggerwcf.
Are you able to try without the AbcWebService
part of the path?
Thinking if there might be any issue handling paths when they are managed by IIS, i.e., not on self-hosted
from swaggerwcf.
So I never did get the routing working, and am still not sure what the issue is. But just in case anyone else experiences something similar, I implemented a workaround by creating another endpoint to retrieve the swagger.json output. The code is below (I apologize for the formatting, I'm not sure what's going on with this editor).
Thank you for your help on this, and feel free to code this ticket.
Interface:
[OperationContract] [DataContractFormat] [WebInvoke(UriTemplate = "swagger.json", Method = "GET", BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json)] object GenerateSwaggerDocumentation();
Implementation
public object GenerateSwaggerDocumentation() { SwaggerWcf.SwaggerWcfEndpoint endpoint = new SwaggerWcf.SwaggerWcfEndpoint(); System.IO.Stream stream = endpoint.GetSwaggerFile(); System.IO.StreamReader reader = new System.IO.StreamReader(stream); string str = reader.ReadToEnd(); var obj = Newtonsoft.Json.Linq.JObject.Parse(str); return obj; }
from swaggerwcf.
Are you able to try without the
AbcWebService
part of the path?Thinking if there might be any issue handling paths when they are managed by IIS, i.e., not on self-hosted
So I never did get the routing working, and am still not sure what the issue is. But just in case anyone else experiences something similar, I implemented a workaround by creating another endpoint to retrieve the swagger.json output. The code is below (I apologize for the formatting, I'm not sure what's going on with this editor).
Thank you for your help on this, and feel free to code this ticket.Interface:
[OperationContract] [DataContractFormat] [WebInvoke(UriTemplate = "swagger.json", Method = "GET", BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json)] object GenerateSwaggerDocumentation();
Implementation
public object GenerateSwaggerDocumentation() { SwaggerWcf.SwaggerWcfEndpoint endpoint = new SwaggerWcf.SwaggerWcfEndpoint(); System.IO.Stream stream = endpoint.GetSwaggerFile(); System.IO.StreamReader reader = new System.IO.StreamReader(stream); string str = reader.ReadToEnd(); var obj = Newtonsoft.Json.Linq.JObject.Parse(str); return obj; }
How do you call this route ? Don't we need an .svc
file for this ? Sorry I'm working on legacy code and I am facing this issue now
from swaggerwcf.
Related Issues (20)
- ServiceContract Attribute
- swagger.json file loses details over time HOT 1
- swaggerwcf CPU 100%
- Models NameSpaces.Class but I want just CLass HOT 3
- Request Error while access external models as parameters
- Swaggerwcf doesn't support ServiceContracts with the same methodsname.
- SwaggerWCF issue with routes and yaml HOT 1
- Adding Basic Authentication
- Adding project as a reference - failed to parse JSON/YAML response
- Unclear instuction WebServiceHost / Self Host HOT 3
- returning multiple types
- Generate multiple-files based on different WCF classes or tags HOT 2
- Request URL HOT 1
- URL issue
- In IIS , response body as "no centent" for swaggerWCF HOT 1
- NullReferenceException on GetEnumDescription
- Enum return value not included in definitions
- How to get Swagger json inside my API ?
- Setting an example value when there's an object on GET method
- ProcessProperty() of TypePropertiesProcessor.cs not handling IList type, Solution here.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swaggerwcf.