C
C#2y ago
.tree

❔ 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
Denis
Denis2y ago
You can create a Swagger file And generate a client from it
.tree
.tree2y ago
I am using swagger in my rest API for documentation
Denis
Denis2y ago
https://editor.swagger.io/ You can paste your swagger here And at the top you can see generators for clients and servers
.tree
.tree2y ago
Ok thats crazy That swagger file, do I write it myself? Or is there a way to auto generate it based on my api?
Anton
Anton2y ago
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.
Anton
Anton2y ago
swagger gives you an endpoint with that file
.tree
.tree2y ago
The file you are talking about is what they call specification, correct?
Anton
Anton2y ago
it's not crazy, it's normal such tool exists well yes
.tree
.tree2y ago
Considering how much easier this makes what I was about to do, it is crazy to me Thank you guys for your help!
Denis
Denis2y ago
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
.tree
.tree2y ago
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?
Denis
Denis2y ago
Do you get an error if you try to put the file into the editor?
.tree
.tree2y ago
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?
Denis
Denis2y ago
That is possible
.tree
.tree2y ago
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?
Anton
Anton2y ago
use NSwag you can automate it
.tree
.tree2y ago
Automate as in it generates my client whenever I make changes to my API?
syao
syao2y ago
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...
Anton
Anton2y ago
as in you run a program and get an updated client
.tree
.tree2y ago
Oh that's even cooler, thank you
Accord
Accord2y ago
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.