What is the prefered method for a 'WSDL' f

2019-03-10 07:37发布

问题:

I have build plenty of SOAP webservices, but am building a REST webservice for a specific project, and I was wondering what people used for a 'WSDL' for REST services or if it is even needed.

回答1:

You can try Swagger(now OpenAPI) which allows to describe REST services using a JSON open standard.



回答2:

REST really only uses the HTTP verbs (GET,PUT,POST,DELETE) on a resource. All operations on a resource are supposed to be represented that way. POST is used as a catch all for when you can't express your business logic in a way that fits into the other three. That is why there isn't really a WSDL for a REST service since you only ever have 4 methods on the resource. Note that the Zend Framework REST library isn't really RESTful and is more of a plain old XML (POX) service.



回答3:

While Sam's correct that RESTful web applications don't need a direct analog to WSDL, there is an XML vocabulary that's useful for describing RESTful web apps: WADL, or Web Application Description Language. At my company we primarily use WADL to define a spec for a given service that we want to build - we don't generally use it programmatically. That said, the WADL home page includes some Java tools for code generation, and Restlet, the Java REST framework, includes a WADL extension for dynamically wiring applications based on WADL and dynamically generating WADL based on a wired application. I'm a fan of WADL, and recommend that you check it out.



回答4:

Actually it's possible to use WSDL for that but it should be v 2.0 - see "Describe REST Web services with WSDL 2.0" article.



回答5:

You can supply an XSD if you are using XML in your REST service.

Or just examples of the XML, should be enough to work things out for simple data structures anyway.