Rookie Ruby/Java developer consuming SOAP

Status
Not open for further replies.

tuxaroni

Wise, Aged Ars Veteran
102
I apologize for dumping my not fully thought trough thoughts on you guys, but I hope to validate if I am on the right track.

At a customer we have a product that integrates against a Web Service. This solution is requested by other customers. Our product use the excellent Savon gem. Unfortunately (in my book) our current solution downloads the WSDL directly and there is no way of validating change in Web Service. Things either work or they brake unpredictable. The difference between working with SOAP messages in Ruby versus static typed languages is that we don't generate proxy classes. I tried to get around this by exporting the WSDL to disk with SoapUI, writing unit tests and mocking the service in Savon, but then I learned that Savon can't handle wsdl:import correctly. If I want to get around that, I assume I have to flatten the WSDL by hand - but I think that's asking to much if we need to do more than one or two integrations.

Instead I am thinking about moving the library to jRuby (Ruby on Java) and just generate Java proxy classes that I call from Ruby code.
  • Is this a good approach for consuming Web Services in "Ruby"?
  • Is it easy to call Java SOAP client and consume the Web Service response from jRuby?
  • I don't have experience with Java SOAP clients. If Web Service change, do we get good validation or error messages from client?

Thanks in advance.
 
D

Deleted member 43669

Guest
Much as I like the strongly-typed approach you want to take here, I don't think it's really needed.

If your concern is that the SOAP endpoint will change- I'm sure you'll be able to catch your SOAP library bombing because of that- it should fail and give you an exception that can be clearly identified as "endpoint changed, oops".

If it can't- well, I think you should change your library- but not necessarily your language. However, you might consider fetching the WSDL regularly and raise an alarm if it changes. This should be pretty easy to implement.
 

tuxaroni

Wise, Aged Ars Veteran
102
[url=http:/civis/viewtopic.php?p=27674681#p27674681:11gzshs9 said:
koala[/url]":11gzshs9]However, you might consider fetching the WSDL regularly and raise an alarm if it changes. This should be pretty easy to implement.

Do you suggest just to temporally download the main WSDL file and do a md5 check on it or something like that?
 

Midlands

Ars Praetorian
535
Subscriptor
I just want to give a counterpoint to the opinion about JRuby above. As background: I have been programming professionally, full-time, in Ruby (some Rails, some just Ruby) since Rails 0.9 in 2005 — so almost ten years.

Given the above scenario, JRuby is exactly what I’d reach for, almost immediately. My experience is that Ruby is a wonderfully productive language, and its libraries are often extremely elegant, but also sometimes lacking in robustness — particularly when it comes to things that Ruby folks tend not to mess around with or like very much. And SOAP is pretty much right at the top of that list.

Java’s almost the opposite: it has absolutely industrial-strength libraries for almost everything, particularly “enterprisey” things like SOAP, but they’re often a huge PITA to work with.

The great thing about JRuby is that you often get the best of both worlds: calling Java libraries I find quite a lot easier with JRuby than with Java, because the integration layer between the two is so good and because Ruby is so much less onerous in many ways. So you end up with the robustness of Java, the scalability of the JVM, and the elegance of Ruby, in many ways.

As an example: I recently built a large-scale, multitenant web crawler that regularly crawls many millions of pages per day from thousands of web sites, extracting content from them for ingestion into a full-text search engine. It’s all built in JRuby, runs on the JVM, and is incredibly stable and robust. I got to use Java’s Thrift libraries (for talking to Kestrel) which are a lot more solid (IME) than Ruby’s, and the Apache Commons HTTPComponents, which, while awkward to talk to (though less so than talking to them from normal Java), are a hell of a lot more stable and reliable than any of the several dozen Ruby HTTP clients that are out there.

There are definitely downsides to JRuby (you can’t fork(2) the JVM or exec(3) from it, relatively slow startup time compared to MRI, you can’t use gems with C extensions), but there are a ton of upsides, too. For me, highly recommended. Not saying my experience is everyone’s — but for this kind of project, I would absolutely seriously consider it.

I’m not saying everyone has exactly my experience, but, for me
 

Zaskar

Ars Praefectus
3,347
Subscriptor
I don't see the problem, did you read the docs?

anyone providing an API has some sort of versioning going on. In the ruby world REST and json version is very simple, it's part of the path /api/v1/:controller/:method/:id

SOAP is a nasty beast but it's part of the schema, look for the UDDI block in a check_and_fail_gracefully call, if YOUR versioned ruby module does not see what it like, toss an exception and log.
 

tuxaroni

Wise, Aged Ars Veteran
102
Thanks for the feedback, especially Midlands long experience and weight on the topic was interesting to learn about. Strangely I did not find much help searching online for a solution and had to gather the pieces by myself. I ended up using JRuby and Apache Axis2 Java library, and it's feels very reliable. If I look past the initial struggle figuring out the jar dependencies and namespace confusion, working with a Java library in Ruby language is very pleasant. It's Java like, but with a friendlier syntax.

I don't see the problem, did you read the docs?

anyone providing an API has some sort of versioning going on. In the ruby world REST and json version is very simple, it's part of the path /api/v1/:controller/:method/:id

SOAP is a nasty beast but it's part of the schema, look for the UDDI block in a check_and_fail_gracefully call, if YOUR versioned ruby module does not see what it like, toss an exception and log.

I just generate the classes with Axis2 and it's solid. I don't get that reliability with MRI alternatives.
 

mungler

Seniorius Lurkius
10
"JRuby makes seasoned Ruby developers cringe."

What a crock! We run a large-scale social network / members club catering for hundreds of thousands of users on a platform based on microservices all running JRuby. It's an exceptional piece of technology, and allows us to leverage Java libraries where necessary. Being able to use Jedis for talking to Redis, for example, is vastly preferable than the usual Ruby implementations. (We also open-sourced our thin Ruby layer around it: https://github.com/asmallworldsite/jedis_rb )

JRuby is a great choice of platform for many reasons - real threads, leveraging of Java libraries, great performance.
 

Drizzt321

Ars Legatus Legionis
34,921
Subscriptor++
Java’s almost the opposite: it has absolutely industrial-strength libraries for almost everything, particularly “enterprisey” things like SOAP, but they’re often a huge PITA to work with.

I do pure Java, and this is very true. Although SOAP plain and simple is a PITA and sucks to work with. Really sucks. I can't describe how much I hate it.

That said, I just use JAX auto-configured proxy stuff (in IntelliJ I right click on the WSDL, generate library) and it just spits out a working (but not pretty) implementation. The one time I had to mess directly with javax.xml.soap stuff was painful. Vaguely interesting, and really not _as_ bad since it was a reasonably sane SOAP API. Although they didn't publish WSDL files, which is why I was implementing it from scratch. MMS MM7 (https://portal.3gpp.org/desktopmodules/Specifications/SpecificationDetails.aspx?specificationId=794). The half-assed existing MM7 Java library (or two) just wouldn't work. Sadly I didn't think about getting my boss on board with posting it on Github before I left the company, so I doubt it's out there anywhere. Pretty niche though.
 
Status
Not open for further replies.