News for hackers. Stuff that matters.
Re:Everything old is new again: Microservices by scarface74 on Wednesday May 09, 2018 @05:57AM (#17028617)
And we went from SOAP to REST because REST with JSON was supposedly simpler.

Then they realized that they needed some type of way to validate the JSON so they introduced JSON schema.

Then they realized that they needed some method to make a REST Api discoverable so they added the Swagger protocol (OpenAI). Now we are right back to being as complicated as SOAP.

Re:Everything old is new again: Microservices by arethuza on Wednesday May 09, 2018 @07:03AM (#17028906)
I think that's a bit harsh - I've been through a number of these cycles: ONC RPCs, CORBA, XML/SOAP and now JSON/JSON Schema/REST and I much prefer the latter.

At least with current JSON and REST API I stand a good chance of experimenting using just an editor and curl - good luck trying that with SOAP.

Re:Everything old is new again: Microservices by scarface74 on Wednesday May 09, 2018 @07:30AM (#17029000)
I didn't do too much with SOAP back in the day and only got into web services while REST was gaining popularity. But when I go back and have to support a "legacy" system and integrate with SOAP, I'm still amazed at the maturity of some of the tooling around SOAP.

REST is getting there.

Re:Everything old is new again: Microservices by arethuza on Wednesday May 09, 2018 @07:35AM (#17029022)
Personally, I think SOAP tooling can be a very leaky abstraction - things are great (e.g. adding a reference to a web service in Visual Studio is trivial) but then when something doesn't work quite as expected (particularly when calling between different tech platforms) debugging could be a nightmare.

My experiences with SOAP were that 99% of the time it was fine - but those other 1% seems to take the other 99% of my time... ;-)

Re:Everything old is new again: Microservices by fuhrysteve on Wednesday May 09, 2018 @08:13AM (#17029191)
Yes, my experience with SOAP is that even well written and maintained clients only work out-of-the-box with like half of the vendor-supplied services you come across.

In many cases, I'll simply formulate xml requests myself and use a generic http request client because the implementation ended up being simpler & easier to maintain than all the confusing hacks I had to do to make zeep or suds (the most popular SOAP clients implemented in python) function properly.

Re:Everything old is new again: Microservices by eropple on Wednesday May 09, 2018 @11:24AM (#17030529)
I don't hate SOAP, and I think it gets a terribly bad rap, but it's pretty easy to spit out a WSDL and not follow it in execution. Ditto OpenAPI, of course, but at least anecdotally it seems like less of a problem. It's not no problem, of course, and one of the reasons I wrote Modern[1], for OpenAPI 3, is to have response validation in development mode, not just request validation mode in dev and prod.

[1] - https://github.com/modern-project/modern-ruby

Re:Everything old is new again: Microservices by arethuza on Wednesday May 09, 2018 @11:47AM (#17030729)
More than one SOAP interface that I encountered in "enterprise" systems consisted basically of:

   string DoStuff(string params)
Where the response and params are strings containing XML documents :-)
Re:Everything old is new again: Microservices by foolfoolz on Wednesday May 09, 2018 @06:11AM (#17028677)
this one is my favorite. seeing my coworkers add swagger and get all excited over a description language for their API.... but then act like WSDL is some abomination is really funny

WSDL is the ultimate api :) it would make my day to see the wsdl comeback of 2018

Re:Everything old is new again: Microservices by reificator on Wednesday May 09, 2018 @07:21AM (#17028968)
One of the service providers we use recently started deprecating their "SOAP" APIs in favor of "REST". Which doesn't bother me because with this provider they're far easier to work with.

But since they provided WSDL before, their "REST" APIs now come with WADL files that offer zero value to anyone. Swagger would be a massive step up from that.

Re:Everything old is new again: Microservices by tannhaeuser on Wednesday May 09, 2018 @06:23AM (#17028737)
The value-add of SOA over "REST" (as in JSON-RPC-over-HTTP) is standardized request/response formats for error messages, distributed transactions, and authentication/authorization, and standardized interface artifacts (WSDL and XSD schemas, policy files).
Re:Everything old is new again: Microservices by dec0dedab0de on Wednesday May 09, 2018 @09:20AM (#17029542)
And we went from SOAP to REST because REST with JSON was supposedly simpler. Then they realized that they needed some type of way to validate the JSON so they introduced JSON schema. Then they realized that they needed some method to make a REST Api discoverable so they added the Swagger protocol (OpenAI). Now we are right back to being as complicated as SOAP.

Except you can ignore the schema and swagger and have it just be simple, if that's all you need.

The biggest problem with SOAP is that it is too easy for the service provider to just dump their internal data structures without any thought to how it should be serialized for people using the data. XML is Particularly nasty in this regard, because it doesn't map well to the data primitives of most dynamic languages.

That said, I usually just treat SOAP APIs as if they were REST. By writing a class, and some wrapper methods for the parts I need. Instead of trying to consume the WSDL and use it the way they envisioned I would. Then again, if Python had better SOAP support I probably wouldn't even do that.

Re:Everything old is new again: Microservices by throwaway2016a on Wednesday May 09, 2018 @08:20AM (#17029226)
SOAP is an absolute nightmare to work with. A WSDL is not even remotely comparable to Swagger.

For one, Swagger is for humans not machines to consume. At it's core it is a way to standardize documentation that can be easily displayed to humans. WSDL is not only used by humans but also by client and server apps.

REST APIs themselves if done right though hypermedia can be self-documenting and require no download of large spec files to use it.

SOAP also suppers from a number of quirks. One for example, that order often matters. Yes you can write a WSDL that doesn't require order but nothing is worse than having a bug because <price> has to appear after <token> but before <expirationMonth> and any other order throws anon-specific validation error. Yes, I know there are tools that can help with this but I have never felt compelled to download a tool for REST. Curl does just fine for me. And to top it off a lot of the best SOAP tools are Windows only.

What I think you really should be pointing at is RPC (of which SOAP is a terrible no good implementation of). RPC indeed offers some benefits over REST and can even be simpler. At the expense of losing the discover and hypermedia aspects of REST if done right.

Re:Everything old is new again: Microservices by tannhaeuser on Wednesday May 09, 2018 @11:32AM (#17030594)
I've been developing so-called "REST" services for over ten years (and SOAP services before that), and not even once were REST principles actually applied in the projects I worked on. As in, the client/browser discovers from an URL the interactions with a resource without out-of-band info for minimal coupling of client and service. I agree though getting SOAP/XML right takes typically considerably more effort than JSON.

Re: statefulness ("order matters"): there are intrinsical stateful processes that aren't represented adequately by a REST service. Think of a basic "Purchase Order" resource representing purchased items on an e-commerce website. You generally can't add and delete line items freely once you have placed your order, but you may cancel individual items (unless they're already physically on your way), you may RMA items, etc. Representing this as a flat "Purchase Order" resource with GET, POST, DELETE, PUT primitives is useless as it isn't telling your web shop front-end developers what actions are available at any one time.

Re:Everything old is new again: Microservices by throwaway2016a on Wednesday May 09, 2018 @12:31PM (#17031214)
> I've been developing so-called "REST" services for over ten years (and SOAP services before that), and not even once were REST principles actually applied in the projects I worked on.

As a consultant who has talked at conferences on APIs and is brought in to explicitly fix these kind of issues I have seen a lot of this too but correct REST APIs do exist. I know because my team builds them.

You're experience is anecdotal and as is mine. But just because a lot of people assume REST is something it isn't doesn't mean REST is inferior to SOAP.

> Re: statefulness ("order matters")

My order matters comment had nothing to do with statefulness. I mean in the XML. In SOP this might work:

  <order>
    <token>ABC</token>
    <price>19.95</price>
  </order>
But this will fail:

  <order>
    <price>19.95</price>
    <token>ABC</token>
  </order>
Why the heck does the order of keys in my object make the API fail!?

Granted that is not a limitation of SOAP but more XML schemas in general. Json is more likely to be order of values agnostic.

But to play devil's advocate I can see the argument where if you are using SOAP to make multiple RPC calls in the same envelope than order is important.

Re:Everything old is new again: Microservices by tannhaeuser on Wednesday May 09, 2018 @01:13PM (#17031642)
Ah ok. But to assemble XML/SOAP for these kind of payloads you'd typically be using a lib such as JAXB, Jackson/gson, Spring (for Java at least) or SCA anyway.

Moreover, you could design your XML Schema such that both variants are accepted (using XSD "all-groups"), though typically record-like data structures are indeed described using XSD sequences which would cause the issue you mentioned. Again I agree XML/XSD isn't a great payload/schema mechanism for data structures such as maps; after all SGML/XML was invented for encoding text. It's being used because it was the first mechanism on the scene, and it continues to be used because it's still much more capable and mature/established in terms of data validation than anything JSON, especially for protocols used in communication with external partners/banks/authorities.

Re:Everything old is new again: Microservices by scarface74 on Wednesday May 09, 2018 @08:51AM (#17029370)
Few implementations add hypermedia support in the real world.

For one, Swagger is for humans not machines to consume. At it's core it is a way to standardize documentation that can be easily displayed to humans.

c# - https://github.com/Azure/autorest

Java - https://github.com/swagger-api/swagger-parser/blob/master/RE...

And basically everything else.

https://github.com/swagger-api/swagger-codegen/blob/master/R...

Re:Everything old is new again: Microservices by throwaway2016a on Wednesday May 09, 2018 @12:34PM (#17031244)
Those are code generators. The code they generate is for the computer. The spec is still an abstraction layer designed for humans.

I am not aware of any code generators that read the swagger file every single API call and use that as if it were the code.

Re:Everything old is new again: Microservices by scarface74 on Thursday May 10, 2018 @03:54PM (#17042399)
How is that any different than a WSDL? A WSDL could also be said to be designed for humans -- it's just XML -- but there are code generators for it too.
Re:Everything old is new again: Microservices by threeseed on Wednesday May 09, 2018 @08:07AM (#17029166)
> Then they realized that they needed some type of way to validate the JSON so they introduced JSON schema.

This is not necessary in many languages that centre around domain objects. The validation is done automatically when the JSON gets mapped back to the object. It's far better than JSON schema anyway since you can enforce whatever custom validation you like.

> Then they realized that they needed some method to make a REST Api discoverable

But it doesn't have to be discoverable. And if you do want it then you could write the documentation by hand or expose a simple REST index endpoint.

> Now we are right back to being as complicated as SOAP.

You chose to make it complicated though.

Re:Everything old is new again: Microservices by _asummers on Wednesday May 09, 2018 @08:51AM (#17029371)
> It's far better than JSON schema anyway since you can enforce whatever custom validation you like.

IMO, the value of JSON Schema isn't that you have no validation that exists outside of JSON Schema, the value is that you can front load a TON of the validation into it, and share that vocabulary between your services. If you publish a JSON Schema about your endpoint, I can read that or feed it into tooling to produce a form to consume it. As someone working on the Elixir JSON Schema lib currently, the places where we COULDN'T express the validation with JSON Schema were often more interesting.

Re:Everything old is new again: Microservices by scarface74 on Wednesday May 09, 2018 @08:25AM (#17029253)
But it doesn't have to be discoverable. And if you do want it then you could write the documentation by hand or expose a simple REST index endpoint.

Like all documentation written by hand, it rapidly gets out of date with the actual implementation if you're not careful.

Also tools can automatically create proxy classes from WSDL's and now Swagger endpoints.

Re:Everything old is new again: Microservices by scruffyherder on Wednesday May 09, 2018 @06:43AM (#17028822)
Nothing like wasting a decade to re-invent everything that was there before.
Re:Everything old is new again: Microservices by godelmachine on Wednesday May 09, 2018 @07:43AM (#17029055)
It's OpenAPI, and not OpenAI :)
Re:Everything old is new again: Microservices by naasking on Wednesday May 09, 2018 @07:55AM (#17029107)
> Then they realized that they needed some method to make a REST Api discoverable

Which is silly, because REST is discoverable by definition, since you should be using hypermedia. And if your API is not discoverable, that's a good sign your service is not actually REST.

Re:Everything old is new again: Microservices by scarface74 on Wednesday May 09, 2018 @08:19AM (#17029221)
The "No True Scotsman" defense seems to be used a lot for REST. Don't get me wrong, I try to stay RESTful as much as possible but hardly anyone writes "truely RESTful APIs".
Re:Everything old is new again: Microservices by naasking on Wednesday May 09, 2018 @09:55AM (#17029812)
> but hardly anyone writes "truely RESTful APIs".

That's pretty much what I said! Web frameworks don't help you at all in this regard, which is why REST is unncessarily difficult to implement. Most web frameworks give you just enough for HTTP-based RPC.

Re:Everything old is new again: Microservices by LargeWu on Wednesday May 09, 2018 @10:29AM (#17030095)
REST is meant to be discoverable by humans, but actually coding to a "true" REST system, using only hypermedia, is a damn nightmare.
Re:Everything old is new again: Microservices by naasking on Wednesday May 09, 2018 @10:55AM (#17030293)
Fielding's thesis doesn't really specify anything in particular about human discoverability, except that REST systems are typically user agent driven compared to typical distributed systems.

As for the nightmare of REST, the real question is whether this difficult is intrinsic, or merely a product of immature tooling and poor understanding. No web framework I've seen, apart from the Waterken server, actually helps you achieve REST. They're largely all HTTP-based RPC frameworks.