❔ Rewrite .NET Framework 4.5.1 SOAP client to REST in .NET 6
I have this SOAP web service that I rewrote to REST. That part wasn't so hard, but now I have to rewrite the SOAP client part. From what I can tell, it's super long .cs that was generated based on two .wsdl files. How do I approach this, do I just throw away the .wsdl files and rewrite the whole thing? I only ever called a REST API in some demo application, how would a best practice real world example look like?
21 Replies
You can create a Swagger file
And generate a client from it
I am using swagger in my rest API for documentation
https://editor.swagger.io/
You can paste your swagger here
And at the top you can see generators for clients and servers
Ok thats crazy
That swagger file, do I write it myself?
Or is there a way to auto generate it based on my api?
GitHub
GitHub - RicoSuter/NSwag: The Swagger/OpenAPI toolchain for .NET, A...
The Swagger/OpenAPI toolchain for .NET, ASP.NET Core and TypeScript. - GitHub - RicoSuter/NSwag: The Swagger/OpenAPI toolchain for .NET, ASP.NET Core and TypeScript.
swagger gives you an endpoint with that file
The file you are talking about is what they call specification, correct?
it's not crazy, it's normal such tool exists
well yes
Considering how much easier this makes what I was about to do, it is crazy to me
Thank you guys for your help!
Just one note. The generator I've sent creates a client that uses newton jsoft. You'll have to modify the code if you don't want to use.said third party library and rather use the native .NET JSON parser from System.Text.Json
That's good to know, thank you
The file I post in the editor is the json file that swagger gives me, right? The one that's linked at the top of the swagger page?
Do you get an error if you try to put the file into the editor?
I do, it's giving me a few semantic errors "GET operations cannot have a requestBody."
Though I assume this is due to mistakes I made in the API?
That is possible
The client that was generated is a .NET Framework project. Would you happen to know if there is an easy way to generate it as a .NET 6 project?
use NSwag
you can automate it
Automate as in it generates my client whenever I make changes to my API?
Rahul Nath
YouTube
NSwag - SWAGGER For ASP.NET CORE and AUTOMATIC Type Generation For ...
Hey Friends, "The OpenAPI Specification, originally known as the Swagger Specification,
is a specification for machine-readable interface files for describing, producing,
consuming, and visualizing RESTful web services"
In this video, I will walk you through on how to set up an OpenAPI spec (Swagger endpoint) for your ASP.NET
Core Web API, us...
as in you run a program and get an updated client
Oh that's even cooler, thank you
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.