Generating .proto file from existing Java objects or xsd
Does anyone know of any tools that will generate a .proto file? Either from an existing xsd or from existing Java objects?
I am using Apache CXF to make a web service call. The returned object has been auto generated from an xsd.
ok so I now want to pass this data using protocol buffe开发者_JS百科rs to another system. The object model is very complex and changes regularly - i.e. I get a new xsd every time the object model has changed. I would like to be able to auto generate a .proto file so that I can send data using google protocol buffers.
I have been looking everywhere but have come stuck.
I am happy to
i.) generate .proto file from the xsd or ii.) generate .proto file from the Java objects (which have been generated from the xsd)
I cannot find any way of doing this already short of writing something myself... Your help much appreciated
The Tranchis utility converts .XSD files to both .Proto and Thrift.
https://github.com/tranchis/xsd2thrift
It works quite well for converting basic schema types from XML Schema.
Try protostuff-runtime-proto
project from Github.
If you have protostuff RuntimeSchema, you can convert it to the .proto file by this code:
System.out.println(Generators.newProtoGenerator(schema).generate());
I believe that proto-stuff will be helpful to you to some extent. I am not sure it generates the .proto file for you but protostuff-runtime automatically enables your existing pojos to ser/deser to various formats.
精彩评论