0

Is there any open source library or online service that could automagicaly generate wsdl spec on the base of the thrift IDL?

The goal is to build facade API on the top of existing thrift API that would allow coupling with ansient systems via SOAP protocol.

Alexander Vasiljev
  • 1,974
  • 3
  • 19
  • 27
  • 1
    At least not OOTB [intentionally I guess](http://grokbase.com/t/thrift/user/09atkr5sfr/wsdl-generation-in-thrift): "*Thrift does not generate WSDL files or implement the SOAP protocol. It certainly could be extended to do so, but most people choose to use Thrift as an alternative to such systems, rather than as complementary.*", but you probaby found that out already. Wonder why someone is willing to go that road at all? SOAP is slow and bloaty. – JensG Jan 19 '17 at 13:18
  • Yep, slow and bloaty. Still swiss knife API of our system is said to support SOAP, as it is intended to integrate with ansient dinosaur systems that still exist here and there. BTW, converting Thrift IDL into plain Java with [fb swift](https://github.com/facebook/swift) and appying [apache axis](https://axis.apache.org/axis2/java/core/) then looks promising so far. – Alexander Vasiljev Jan 19 '17 at 14:25
  • 1
    Cool, thanks for the insight. Consider rephrasing your question, post an answer to it, and even accept it. So if you find something that sounds suitable: Why not tell the world? ;-) -- Unfortunately, we also have to support SOAP but our approach is a bit different. We generate both WSDL and IDL from a third source using a homegrown tool. Not ideal, but works Good Enough™ – JensG Jan 19 '17 at 22:28

1 Answers1

0

There are a couple of ready to use tools that allow to convert Thrift IDL into WSDL. The rest of the answer assumes we live in the Java world with JDK and Maven at hand and internet connection available.


The first one is Swift Code Generator Tool. As it's readme states, one have to:

  1. download the latest version:

    mvn org.apache.maven.plugins:maven-dependency-plugin:2.8:get -DremoteRepositories=central::default::http://repo1.maven.apache.org/maven2 -Dartifact=com.facebook.swift:swift-generator-cli:RELEASE:jar:standalone -Ddest=/tmp/
    
  2. run downloaded jar in the directory containing thrift files:

    java -jar /tmp/swift-generator-cli-0.23.1-standalone.jar -use_java_namespace -out ../java *.thrift
    

assuming standard

- src
  - main
    - java
    - thrift

Maven project layout. Swift Code Generator will generate a Java interface for each Thrift service entry. Every Thrift source file must declare a 'java' namespace, like this:

namespace java com.acme

The generated interface will include nested Async interface for asynchronous invocation. Remove Async subinterface. Automation of Async removal is left as an exercise for the reader.


Compile generated java files with javac or your favourite build tool (ant, maven, gradle, etc.). Do not forget to include com.facebook.swift:swift-annotations:0.23.1 as a compile dependency.


Finally use Apache Axis2' java2wsdl utility available within Axis2 binary distribution, like this:

/tmp/axis2-1.7.4/bin/java2wsdl.sh -cn com.acme.TargetService -cp build/classes/main

to generate wsdl for the Thrift service TargetService {...} entry.

Alexander Vasiljev
  • 1,974
  • 3
  • 19
  • 27