GithubHelp home page GithubHelp logo

Comments (6)

abelsilva avatar abelsilva commented on July 23, 2024

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.

loweva avatar loweva commented on July 23, 2024

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.

loweva avatar loweva commented on July 23, 2024

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.

abelsilva avatar abelsilva commented on July 23, 2024

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.

loweva avatar loweva commented on July 23, 2024

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.

gethari avatar gethari commented on July 23, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.