简体   繁体   中英

What is the prefered method for a 'WSDL' for REST webservice?

我已经构建了大量的SOAP Web服务,但我正在为特定的项目构建一个REST Web服务,我想知道人们用于REST服务的'WSDL'是什么,或者甚至是否需要它。

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.

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.

您可以尝试使用Swagger (现在的OpenAPI),它允许使用JSON开放标准来描述REST服务。

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM