{"id":506,"date":"2011-08-20T15:28:00","date_gmt":"2011-08-20T15:28:00","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/2012\/10\/web-services-in-ruby-python-and-java.html"},"modified":"2012-10-21T20:06:22","modified_gmt":"2012-10-21T20:06:22","slug":"web-services-ruby-python-java","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2011\/08\/web-services-ruby-python-java.html","title":{"rendered":"Web Services in Ruby, Python and Java"},"content":{"rendered":"<div dir=\"ltr\" style=\"text-align: left\">Today I\u2019ve had to prepare some examples to show that web services are interoperable. So I\u2019ve created a simple web service in Java using Metro and launched it on Tomcat.<\/p>\n<p>Then tried to consume them using Python and Ruby. Here\u2019s how it all finished\u2026<\/p>\n<p><span style=\"font-weight: bold\">Web service in Java<\/span><\/p>\n<p>I\u2019ve started with a simple web service in Java:<\/p>\n<pre class=\"brush:java\">package com.wordpress.jdevel.ws;\r\n\r\nimport java.io.File;\r\nimport java.io.FileFilter;\r\nimport java.io.FilenameFilter;\r\nimport java.util.ArrayList;\r\nimport java.util.List;\r\nimport javax.jws.WebService;\r\nimport javax.jws.WebMethod;\r\nimport javax.jws.WebParam;\r\n\r\n@WebService(serviceName = \"Music\")\r\npublic class Music {\r\n\r\n    private static final File FOLDER = new File(\"D:\/TEMP\/SONGS\");\r\n\r\n    @WebMethod(operationName = \"listSongs\")\r\n    public Song[] listSongs(@WebParam(name = \"artist\") String artist) {\r\n\r\n        List&lt;Song&gt; songs = new ArrayList&lt;Song&gt;();\r\n        System.out.println(\"ARTIST: \" + artist);\r\n        if (artist != null) {\r\n            File folder = new File(FOLDER, artist);\r\n            if (folder.exists() &amp;&amp; folder.isDirectory()) {\r\n                File[] listFiles = folder.listFiles(new FilenameFilter() {\r\n\r\n                    public boolean accept(File dir, String name) {\r\n                        return name.toUpperCase().endsWith(\".MP3\");\r\n                    }\r\n                });\r\n\r\n                for (File file : listFiles) {\r\n                    String fileName = file.getName();\r\n                    String author = file.getParentFile().getName();\r\n                    int size = (int) (file.length() \/ 1048576); \/\/Megabytes\r\n                    Song song = new Song(fileName, author, size);\r\n                    songs.add(song);\r\n                }\r\n            }\r\n        }\r\n\r\n        return songs.toArray(new Song[songs.size()]);\r\n    }\r\n\r\n    @WebMethod(operationName = \"listArtists\")\r\n    public String[] listArtists() {\r\n        File[] folders = getFolders(FOLDER);\r\n        List&lt;String&gt; artists = new ArrayList&lt;String&gt;(folders.length);\r\n        for (File folder : folders) {\r\n            artists.add(folder.getName());\r\n        }\r\n        return artists.toArray(new String[artists.size()]);\r\n    }\r\n\r\n    private File[] getFolders(File parent) {\r\n        FileFilter filter = new FileFilter() {\r\n\r\n            public boolean accept(File pathname) {\r\n                return pathname.isDirectory();\r\n            }\r\n        };\r\n\r\n        File[] folders = parent.listFiles(filter);\r\n\r\n        return folders;\r\n    }\r\n\r\n    public static void main(String[] args) {\r\n        Music listFiles = new Music();\r\n        String[] artists = listFiles.listArtists();\r\n        System.out.println(\"Artists: \" + artists);\r\n        for (String artist : artists) {\r\n            Song[] listSongs = listFiles.listSongs(artist);\r\n            for (Song song : listSongs) {\r\n                System.out.println(song.getArtist() + \" : \" + song.getFileName() + \" : \" + song.getSize() + \"MB\");\r\n            }\r\n        }\r\n    }\r\n}\r\n<\/pre>\n<p>Needed also a simple bean to get some more complex types:<\/p>\n<pre class=\"brush:java\">package com.wordpress.jdevel.ws;\r\n\r\nimport java.io.Serializable;\r\n\r\npublic class Song implements Serializable {\r\n    String fileName;\r\n    String artist;\r\n    int size;\r\n\r\n    public Song() {\r\n    }\r\n\r\n    public Song(String fileName, String artist, int size) {\r\n        this.fileName = fileName;\r\n        this.artist = artist;\r\n        this.size = size;\r\n    }\r\n\r\n    public String getArtist() {\r\n        return artist;\r\n    }\r\n\r\n    public void setArtist(String artist) {\r\n        this.artist = artist;\r\n    }\r\n\r\n    public String getFileName() {\r\n        return fileName;\r\n    }\r\n\r\n    public void setFileName(String fileName) {\r\n        this.fileName = fileName;\r\n    }\r\n\r\n    public int getSize() {\r\n        return size;\r\n    }\r\n\r\n    public void setSize(int size) {\r\n        this.size = size;\r\n    }\r\n}\r\n<\/pre>\n<p>It\u2019s just listing all sub-directories in hardcoded FOLDER directory and treats it as list of artists in music collection. Then you can execute listSongs method and get list of mp3 files in artist sub-folder.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p>To make it a web service all you have to do is annotate class with @WebService(serviceName = &#8220;Music&#8221;) and every method you want to expose as web service operation has to be marked with @WebMethod(operationName = &#8220;listArtists&#8221;).<\/p>\n<p>This should be all if you\u2019re deploying it on GlassFish, but I\u2019ve used Tomcat, so 3 more steps were needed:<\/p>\n<p>1. Add Metro 2.0 jars to WEB-INF\/lib<br \/>\n2. Add Metro servlet and listener to web.xml:<\/p>\n<pre class=\"brush:xml\">&lt;listener&gt;\r\n\t&lt;listener-class&gt;\r\n\t\tcom.sun.xml.ws.transport.http.servlet.WSServletContextListener\r\n\t&lt;\/listener-class&gt;\r\n&lt;\/listener&gt;\r\n&lt;servlet&gt;\r\n\t&lt;servlet-name&gt;Music&lt;\/servlet-name&gt;\r\n\t&lt;servlet-class&gt;com.sun.xml.ws.transport.http.servlet.WSServlet&lt;\/servlet-class&gt;\r\n\t&lt;load-on-startup&gt;1&lt;\/load-on-startup&gt;\r\n&lt;\/servlet&gt;\r\n&lt;servlet-mapping&gt;\r\n\t&lt;servlet-name&gt;Music&lt;\/servlet-name&gt;\r\n\t&lt;url-pattern&gt;\/Music&lt;\/url-pattern&gt;\r\n&lt;\/servlet-mapping&gt;\r\n<\/pre>\n<p>You probably shouldn\u2019t change anything here. Just paste it to your web.xml in web-app node.<\/p>\n<p>3. Add sun-jaxws.xml file to WEB-INF with endpoint declaration:<\/p>\n<pre class=\"brush:xml\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\r\n&lt;endpoints version=\"2.0\" xmlns=\"http:\/\/java.sun.com\/xml\/ns\/jax-ws\/ri\/runtime\"&gt;\r\n\t&lt;endpoint implementation=\"com.wordpress.jdevel.ws.Music\" name=\"Music\" url-pattern=\"\/Music\"\/&gt;\r\n&lt;\/endpoints&gt;\r\n<\/pre>\n<ul>\n<li>implementation has to match your @WebService class<\/li>\n<li>name has to match serviceName in @WebService annotation<\/li>\n<li>url-pattern has to match url-pattern you have declared in servlet mapping<\/li>\n<\/ul>\n<p>There should also be no need to edit these xml files if you create it in NetBeans.<\/p>\n<p>Now start Tomcat and deploy your app. You should be able to access your service via something like<\/p>\n<p><a href=\"http:\/\/localhost:8080\/WSServer\/Music\">http:\/\/localhost:8080\/WSServer\/Music<\/a><\/p>\n<p>and see something like this:<\/p>\n<p><a href=\"http:\/\/3.bp.blogspot.com\/-anvu1M1lrto\/Tk-AyiMbG7I\/AAAAAAAAAFs\/m4zPLlx9WUM\/s1600\/web-services.png\"><img decoding=\"async\" alt=\"\" border=\"0\" src=\"http:\/\/3.bp.blogspot.com\/-anvu1M1lrto\/Tk-AyiMbG7I\/AAAAAAAAAFs\/m4zPLlx9WUM\/s320\/web-services.png\" style=\"cursor: hand;cursor: pointer;height: 139px;margin: 0px auto 10px;text-align: center;width: 320px\" \/><\/a><\/p>\n<p>WSDL will be accessible via<\/p>\n<p><a href=\"http:\/\/localhost:8080\/WSServer\/Music?wsdl\">http:\/\/localhost:8080\/WSServer\/Music?wsdl<\/a><\/p>\n<p>Schema for complex types:<\/p>\n<p><a href=\"http:\/\/localhost:8080\/WSServer\/Music?xsd=1\">http:\/\/localhost:8080\/WSServer\/Music?xsd=1<\/a><\/p>\n<p>If you got this working, you can start with the following clients.<\/p>\n<p><span style=\"font-weight: bold\">Python Client<\/span><br \/>\nI\u2019ve started googling for some nice web services library for python and found Suds. I haven\u2019t really used anything like this. Implementing WS client took me about 15 minutes. Supporting complex types of course and last time I\u2019ve been using Python for something bigger than 5 lines was about 3 years ago. You really have to try it out.<\/p>\n<p>So here\u2019s the code:<\/p>\n<pre class=\"brush:java\">import suds\r\n\r\nclass Client:\r\n    def __init__(self):\r\n        self.client = suds.client.Client(\"http:\/\/localhost:8080\/WSServer\/Music?wsdl\")\r\n\r\n    def get_artists(self):\r\n        return self.client.service.listArtists()\r\n\r\n    def get_songs(self, artist):\r\n        return self.client.service.listSongs(artist)\r\n\r\nif(__name__ == \"__main__\"):\r\n    client = Client()\r\n    artists = client.get_artists()\r\n    for artist in artists:\r\n        print artist\r\n        songs = client.get_songs(artist)\r\n        for song in songs:\r\n            print \"\\t%s : %s : %d%s\" % (song.fileName, song.artist, song.size, \"MB\")\r\n<\/pre>\n<p>That\u2019s it. Plain simple. WSDL is parsed, complex types get generated on the fly. Something beautiful. It was little bit more difficult for me to implement something like this in&#8230;<\/p>\n<p><strong>Ruby Client<\/strong><br \/>\nUsing SOAP4R library. Just execute<\/p>\n<p>gem install soap4r<\/p>\n<p>to get it (really love this tool).First let\u2019s start with the code:<\/p>\n<pre class=\"brush:java\">require 'soap\/rpc\/driver'\r\nrequire 'soap\/wsdlDriver'\r\n\r\nclass Client\r\n  def initialize\r\n    factory = SOAP::WSDLDriverFactory.new(\"http:\/\/localhost:8080\/WSServer\/Music?wsdl\")\r\n    @driver = factory.create_rpc_driver\r\n  end\r\n\r\n  def get_songs(artist)\r\n    songs = @driver.listSongs(:artist =&gt; artist)\r\n    return songs\r\n  end\r\n\r\n  def get_artists\r\n    artists = @driver.listArtists(nil)\r\n    return artists\r\n  end\r\nend\r\n\r\ndef print_songs(songs)\r\n  if songs\r\n\r\n  end\r\nend\r\n\r\nclient = Client.new\r\nartists = client.get_artists\r\nartists[\"return\"].each{|artist|\r\n  puts artist\r\n  songs = client.get_songs(artist)[\"return\"];\r\n  songs.each {|song| puts \"\\t%s : %s : %d%s\" % [song.fileName, song.artist, song.size, \"MB\"]}\r\n}\r\n<\/pre>\n<p>It does exactly the same. Calls web service for list of artists and then, for each artist calls for mp3 files. Then just prints everything out to console.<\/p>\n<p>It took me quite a while to get it working. First of all \u2013 it\u2019s quite hard to find any documentation. Second \u2013 SOAP4R does not work with ruby 1.9 without little hacking:<\/p>\n<p><a href=\"http:\/\/railsforum.com\/viewtopic.php?id=41231\">http:\/\/railsforum.com\/viewtopic.php?id=41231<\/a><\/p>\n<p>Next \u2013 when you don\u2019t use WSDL to create driver object results are little bit better, but then you exactly have to know what services you have and want to execute. It\u2019s not a problem in this simple example, but if you need to make it little bit more generic\u2026 you\u2019ll in trouble.<\/p>\n<p>What do I mean by \u201clittle bit better\u201d? First, the code:<\/p>\n<pre class=\"brush:java\">@driver = SOAP::RPC::Driver.new(\"http:\/\/localhost:8080\/WSServer\/Music\", \"http:\/\/ws.jdevel.wordpress.com\/\");\r\n@driver.add_method(ARTISTS_METHOD)\r\n@driver.add_method(SONGS_METHOD, \"artist\")\r\n<\/pre>\n<p>This way I\u2019m responsible for declaring endpoint and namespace for service I want to use. I also need to declare all operations I\u2019m going to use, also with parameters (\u201cauthor\u201d). What\u2019s the difference? When I don\u2019t use WSDL SOAP4R library gives much better return types from invoking services. I can simply omit [&#8220;return&#8221;] and get something like using Python.<\/p>\n<p>What i do need to know in Ruby is how does each complex type look like thus makes my implementation more sensitive for web service change. How to know what key you should use to get data you have in complex type? Check WSDL and look for operation you want to call:<\/p>\n<pre class=\"brush:xml\">&lt;operation name=\"listArtists\"&gt;\r\n    &lt;input wsam:Action=\"http:\/\/ws.jdevel.wordpress.com\/Music\/listArtistsRequest\" message=\"tns:listArtists\"\/&gt;\r\n    &lt;output wsam:Action=\"http:\/\/ws.jdevel.wordpress.com\/Music\/listArtistsResponse\" message=\"tns:listArtistsResponse\"\/&gt;\r\n&lt;\/operation&gt;\r\n<\/pre>\n<p>Next find output complex type in xsd<\/p>\n<pre class=\"brush:xml\">&lt;xs:complexType name=\"listArtistsResponse\"&gt;\r\n    &lt;xs:sequence&gt;\r\n        &lt;xs:element name=\"return\" type=\"xs:string\" nillable=\"true\" minOccurs=\"0\" maxOccurs=\"unbounded\"\/&gt;\r\n    &lt;\/xs:sequence&gt;\r\n&lt;\/xs:complexType&gt;\r\n<\/pre>\n<p>What you need is value of name attribute. Anyway, both implementations look really nice and, whats more important, work fine. Both Ruby and Python have nice web services libraries that handle complex types and WSDL parsing. <\/p>\n<p><strong><i>Reference: <\/i><\/strong><a href=\"http:\/\/jdevel.wordpress.com\/2011\/05\/28\/web-services-in-ruby-python-and-java\/\">Web Services in Ruby, Python and Java<\/a> from our <a href=\"http:\/\/www.javacodegeeks.com\/p\/jcg.html\">JCG partner<\/a> at the <a href=\"http:\/\/jdevel.wordpress.com\/\">&#8220;Development world stories&#8221; blog<\/a>.<\/p>\n<div style=\"margin: 0px\"><strong><i>Related Articles :<\/i><\/strong><\/div>\n<ul>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2010\/11\/jaxws-with-spring-and-maven-tutorial.html\">JAX\u2013WS with Spring and Maven Tutorial<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2011\/03\/java-json-processing-jackson.html\">Java JSON processing with Jackson<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2010\/06\/spring-3-restful-web-services.html\">Spring 3 RESTful Web Services<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2011\/07\/jqgrid-rest-ajax-spring-mvc-integration.html\">jqGrid, REST, AJAX and Spring MVC Integration<\/a><\/li>\n<\/ul>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Today I\u2019ve had to prepare some examples to show that web services are interoperable. So I\u2019ve created a simple web service in Java using Metro and launched it on Tomcat. Then tried to consume them using Python and Ruby. Here\u2019s how it all finished\u2026 Web service in Java I\u2019ve started with a simple web service &hellip;<\/p>\n","protected":false},"author":47,"featured_media":225,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[32,224,223,106],"class_list":["post-506","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-apache-tomcat","tag-python","tag-ruby","tag-web-services"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Web Services in Ruby, Python and Java - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Today I\u2019ve had to prepare some examples to show that web services are interoperable. So I\u2019ve created a simple web service in Java using Metro and launched\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2011\/08\/web-services-ruby-python-java.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Web Services in Ruby, Python and Java - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Today I\u2019ve had to prepare some examples to show that web services are interoperable. So I\u2019ve created a simple web service in Java using Metro and launched\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2011\/08\/web-services-ruby-python-java.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2011-08-20T15:28:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2012-10-21T20:06:22+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/ruby-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Marek Piechut\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Marek Piechut\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/08\\\/web-services-ruby-python-java.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/08\\\/web-services-ruby-python-java.html\"},\"author\":{\"name\":\"Marek Piechut\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/cce61c48dbfcdcaf98a6d5d04de659ce\"},\"headline\":\"Web Services in Ruby, Python and Java\",\"datePublished\":\"2011-08-20T15:28:00+00:00\",\"dateModified\":\"2012-10-21T20:06:22+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/08\\\/web-services-ruby-python-java.html\"},\"wordCount\":770,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/08\\\/web-services-ruby-python-java.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/ruby-logo.jpg\",\"keywords\":[\"Apache Tomcat\",\"Python\",\"Ruby\",\"Web Services\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/08\\\/web-services-ruby-python-java.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/08\\\/web-services-ruby-python-java.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/08\\\/web-services-ruby-python-java.html\",\"name\":\"Web Services in Ruby, Python and Java - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/08\\\/web-services-ruby-python-java.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/08\\\/web-services-ruby-python-java.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/ruby-logo.jpg\",\"datePublished\":\"2011-08-20T15:28:00+00:00\",\"dateModified\":\"2012-10-21T20:06:22+00:00\",\"description\":\"Today I\u2019ve had to prepare some examples to show that web services are interoperable. So I\u2019ve created a simple web service in Java using Metro and launched\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/08\\\/web-services-ruby-python-java.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/08\\\/web-services-ruby-python-java.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/08\\\/web-services-ruby-python-java.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/ruby-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/ruby-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/08\\\/web-services-ruby-python-java.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/enterprise-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Web Services in Ruby, Python and Java\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/cce61c48dbfcdcaf98a6d5d04de659ce\",\"name\":\"Marek Piechut\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d17285d804bef2cc266817ab1d5ed655a8cc7461cc6bbcd3cb191a127071b7d5?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d17285d804bef2cc266817ab1d5ed655a8cc7461cc6bbcd3cb191a127071b7d5?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d17285d804bef2cc266817ab1d5ed655a8cc7461cc6bbcd3cb191a127071b7d5?s=96&d=mm&r=g\",\"caption\":\"Marek Piechut\"},\"sameAs\":[\"http:\\\/\\\/jdevel.wordpress.com\\\/\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/Marek-Piechut\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Web Services in Ruby, Python and Java - Java Code Geeks","description":"Today I\u2019ve had to prepare some examples to show that web services are interoperable. So I\u2019ve created a simple web service in Java using Metro and launched","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/2011\/08\/web-services-ruby-python-java.html","og_locale":"en_US","og_type":"article","og_title":"Web Services in Ruby, Python and Java - Java Code Geeks","og_description":"Today I\u2019ve had to prepare some examples to show that web services are interoperable. So I\u2019ve created a simple web service in Java using Metro and launched","og_url":"https:\/\/www.javacodegeeks.com\/2011\/08\/web-services-ruby-python-java.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2011-08-20T15:28:00+00:00","article_modified_time":"2012-10-21T20:06:22+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/ruby-logo.jpg","type":"image\/jpeg"}],"author":"Marek Piechut","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Marek Piechut","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2011\/08\/web-services-ruby-python-java.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/08\/web-services-ruby-python-java.html"},"author":{"name":"Marek Piechut","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/cce61c48dbfcdcaf98a6d5d04de659ce"},"headline":"Web Services in Ruby, Python and Java","datePublished":"2011-08-20T15:28:00+00:00","dateModified":"2012-10-21T20:06:22+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/08\/web-services-ruby-python-java.html"},"wordCount":770,"commentCount":1,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/08\/web-services-ruby-python-java.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/ruby-logo.jpg","keywords":["Apache Tomcat","Python","Ruby","Web Services"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2011\/08\/web-services-ruby-python-java.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2011\/08\/web-services-ruby-python-java.html","url":"https:\/\/www.javacodegeeks.com\/2011\/08\/web-services-ruby-python-java.html","name":"Web Services in Ruby, Python and Java - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/08\/web-services-ruby-python-java.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/08\/web-services-ruby-python-java.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/ruby-logo.jpg","datePublished":"2011-08-20T15:28:00+00:00","dateModified":"2012-10-21T20:06:22+00:00","description":"Today I\u2019ve had to prepare some examples to show that web services are interoperable. So I\u2019ve created a simple web service in Java using Metro and launched","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/08\/web-services-ruby-python-java.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2011\/08\/web-services-ruby-python-java.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2011\/08\/web-services-ruby-python-java.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/ruby-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/ruby-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2011\/08\/web-services-ruby-python-java.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/enterprise-java"},{"@type":"ListItem","position":4,"name":"Web Services in Ruby, Python and Java"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/cce61c48dbfcdcaf98a6d5d04de659ce","name":"Marek Piechut","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/d17285d804bef2cc266817ab1d5ed655a8cc7461cc6bbcd3cb191a127071b7d5?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/d17285d804bef2cc266817ab1d5ed655a8cc7461cc6bbcd3cb191a127071b7d5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d17285d804bef2cc266817ab1d5ed655a8cc7461cc6bbcd3cb191a127071b7d5?s=96&d=mm&r=g","caption":"Marek Piechut"},"sameAs":["http:\/\/jdevel.wordpress.com\/"],"url":"https:\/\/www.javacodegeeks.com\/author\/Marek-Piechut"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/506","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/47"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=506"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/506\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/225"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=506"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=506"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=506"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}