Forgot Password

I choose Java over Python when doing XML, SOAP and XSD!

Recently I started working on a project that has to be working with SOAP services. Obviously I started working with Python to do the job, Python is my knife to stab many kind of problem, well this time I got it all wrong.

Python has some great tools to work XML and SOAP, but it wasn't enough. In this project I was given tons of XSD files to work with and when I'm saying XSD files, I'm talking about OTA schema files, they are big.

When working with Schema files, what so ever you need, you have to make classes out of each XSD file in order to work easily with them. Constructing valid XML based on the given Schema is not something you want to do manually, especially when your XSD alone is 10K lines with 2 other schema files included on top of it.

It's a big bombastic surrounding mess. 

Alright, in order to make shiny Python classes out of the Schema file I used generateDS and PyXB and they worked but they didn't work. For each generated class there was at least 200K lines of Python code, no easy way to look into them , opening them would make the  text editor or my IDE going crazy, hearing the CPU fan screaming was not something joyful and not knowing how to work with the generated classes was worst. Keep in mind, generating the Python classes from those schema files requires you to go through tons of command line work and trying to fix many weird problems. They're certainly great tools, but they weren't for my case.

I decided to let the Python pass and give it a rest for this problem and started looking into beloved Java. A thing that took me ~2 weeks, was exactly 3 hours in Java this time. I got all the stuff I wanted in couple of lookups.

You wanna work with XML? There's XSD and schema files involved ? GET TO JAVA!

To make all the classes working I needed to get command line tools JAXB "XJC" from the internet and run it on the Schema files. I just give it the XSD directory and it generated all the Java classes from the given schema files.

Results were very light, bunch of Java classes that were easy to read and use and I was able to

I guess I was very late to the Java XML party, doing all the stuff in Python for several years made me lazy to try such beautiful tools and ecosystem.

Some helpful resources:

Alireza Savand • 2018 Feb 25

Be the first to comment.