{
  "version": "https://jsonfeed.org/version/1.1",
  "title": "chem-bla-ics",
  "description": "Chemblaics (pronounced chem-bla-ics) is the science that uses open science and computers to solve problems in chemistry, biochemistry and related fields.",
  "home_page_url": "https://chem-bla-ics.linkedchemistry.info/",
  "feed_url": "https://chem-bla-ics.linkedchemistry.info/2008/11/04/next-generation-asynchronous.json",
  "icon": "https://chem-bla-ics.linkedchemistry.info/assets/images/chem-bla-ics_logo.png",
  "language": "en",
  "authors": [
    {
      "name": "Egon Willighagen",
      "url": "https://orcid.org/0000-0001-7542-0286",
      "_orcid": "0000-0001-7542-0286"
    }
  ],
  "items": [

    {
      "id": "https://doi.org/10.59350/esdth-ef628",
      "url": "https://chem-bla-ics.linkedchemistry.info/2008/11/04/next-generation-asynchronous.html",
      "title": "Next generation asynchronous webservices #2",
      "content_html": "<p>Getting back to some webservice stuff (see <a href=\"https://chem-bla-ics.linkedchemistry.info/2008/10/31/next-generation-asynchronous.html\">part #1 of this series <i class=\"fa-solid fa-recycle fa-xs\"></i></a>)…\nactually, I’ll use <em>cloud service</em> from now on, since <em>web service</em> is reserved for SOAP/WSDL (see\n<a href=\"https://chem-bla-ics.linkedchemistry.info/2008/11/03/embrace-workshop-in-uppsala.html\">my EMBRACE presentation <i class=\"fa-solid fa-recycle fa-xs\"></i></a>).\nLet me present this bit of JavaScript I just ran in Bioclipse2:</p>\n\n<div class=\"language-javascript highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"nx\">xws</span><span class=\"p\">.</span><span class=\"nf\">connect</span><span class=\"p\">();</span>\n<span class=\"nx\">service</span> <span class=\"o\">=</span> <span class=\"nx\">xws</span><span class=\"p\">.</span><span class=\"nf\">getService</span><span class=\"p\">(</span><span class=\"dl\">\"</span><span class=\"s2\">cdk.ws1.bmc.uu.se</span><span class=\"dl\">\"</span><span class=\"p\">);</span>\n<span class=\"nx\">service</span><span class=\"p\">.</span><span class=\"nf\">discoverSync</span><span class=\"p\">(</span><span class=\"mi\">9000</span><span class=\"p\">);</span>\n<span class=\"nx\">service</span><span class=\"p\">.</span><span class=\"nf\">getFunctions</span><span class=\"p\">();</span>\n<span class=\"nx\">f</span> <span class=\"o\">=</span> <span class=\"nx\">service</span><span class=\"p\">.</span><span class=\"nf\">getFunction</span><span class=\"p\">(</span><span class=\"dl\">\"</span><span class=\"s2\">calculateMass</span><span class=\"dl\">\"</span><span class=\"p\">);</span>\n<span class=\"nx\">ios</span> <span class=\"o\">=</span> <span class=\"nx\">f</span><span class=\"p\">.</span><span class=\"nf\">getIoSchemataSync</span><span class=\"p\">(</span><span class=\"mi\">9000</span><span class=\"p\">);</span>\n<span class=\"nx\">iof</span> <span class=\"o\">=</span> <span class=\"nx\">xws</span><span class=\"p\">.</span><span class=\"nf\">getIoFactory</span><span class=\"p\">(</span><span class=\"nx\">ios</span><span class=\"p\">);</span>\n<span class=\"nx\">smiDoc</span> <span class=\"o\">=</span> <span class=\"nx\">iof</span><span class=\"p\">.</span><span class=\"nf\">createSmilesDocument</span><span class=\"p\">();</span>\n<span class=\"nx\">smiDoc</span><span class=\"p\">.</span><span class=\"nf\">setSmiles</span><span class=\"p\">(</span><span class=\"dl\">\"</span><span class=\"s2\">CCC</span><span class=\"dl\">\"</span><span class=\"p\">);</span>\n<span class=\"nx\">result</span> <span class=\"o\">=</span> <span class=\"nx\">f</span><span class=\"p\">.</span><span class=\"nf\">invokeSync</span><span class=\"p\">(</span><span class=\"nx\">smiDoc</span><span class=\"p\">.</span><span class=\"nf\">toString</span><span class=\"p\">(),</span> <span class=\"mi\">9000</span><span class=\"p\">);</span>\n<span class=\"nx\">obj</span> <span class=\"o\">=</span> <span class=\"nx\">iof</span><span class=\"p\">.</span><span class=\"nf\">getOutputObject</span><span class=\"p\">(</span><span class=\"nx\">result</span><span class=\"p\">);</span>\n<span class=\"nf\">print</span><span class=\"p\">(</span><span class=\"dl\">\"</span><span class=\"s2\">Mass: </span><span class=\"dl\">\"</span> <span class=\"o\">+</span>  <span class=\"nx\">obj</span><span class=\"p\">.</span><span class=\"nf\">getStringValue</span><span class=\"p\">())</span>\n</code></pre></div></div>\n\n<p>At first, it might look a bit verbose to just calculate the mass of a molecule, and it is, and it is not even written in XML. Hahahaha</p>\n\n<p>Anyway, the code rocks, thanx to Johannes’ great work on his <a href=\"https://sourceforge.net/projects/xws4j/\">xws4j</a> library! I’ll explain\nthe script. The first line gets Bioclipse online using a <em>Jabber</em> account, which you set via Bioclipse’ preferences pages. The next few\nlines allows you to connect to a cloud service, this one running on <code class=\"language-plaintext highlighter-rouge\">ws1.bmc.uu.se</code> and called <code class=\"language-plaintext highlighter-rouge\">cdk</code>. With the <code class=\"language-plaintext highlighter-rouge\">getFunctions()</code> method\nwe query which functions are available, called ports in WDSL if not mistaken, from which we pick the <code class=\"language-plaintext highlighter-rouge\">calculateMass</code> one.</p>\n\n<p>And then the action joins in. One nice feature of the <a href=\"http://xmpp.org/extensions/xep-0244.html\">IO-DATA proposal</a> is that the function\nitself defines the XML Schema it uses for input and output, and does not rely on WDSL to do that (or maybe recent SOAP specs allows that\ntoo). So, we query the function for its schemata, and the xws4j library then something funky happens: we order the library to create a\ndata model on the fly for this service! From this we get a Java data model for the service. This allows us to use <code class=\"language-plaintext highlighter-rouge\">createSmilesDocument()</code>\nand <code class=\"language-plaintext highlighter-rouge\">setSmiles()</code>. That’s function-specific stuff!</p>\n\n<p>Of course, we do not have to do that. For example, the second function I wrote (<code class=\"language-plaintext highlighter-rouge\">generate3Dcoordinates</code>) eats and spits CML, and I’d\nrather rely on CMLDOM or CDK as data model then. But more on that later…</p>\n\n<p>The Bioclipse xws4j plugin actually puts the data model in my workspace, so that I can easily introspect the API:</p>\n\n<p><img src=\"/assets/images/autogeneration.png\" alt=\"\" /></p>\n\n<p>The last three lines invoke the function (synchronously, as it’s cheap), and get the mass from the function output. BTW, I should\nstress that a function does not require any specific implementation regarding synchronous or asynchronous calls. You write <strong>one</strong>\nfunction, and can call it in either way you like. The library hides all IO-DATA details around that.</p>",
      "summary": "Getting back to some webservice stuff (see part #1 of this series )… actually, I’ll use cloud service from now on, since web service is reserved for SOAP/WSDL (see my EMBRACE presentation ). Let me present this bit of JavaScript I just ran in Bioclipse2:",
      "image": "https://chem-bla-ics.linkedchemistry.info/assets/images/autogeneration.png",
      "date_published": "2008-11-04T00:00:00+00:00",
      "date_modified": "2025-10-11T00:00:00+00:00",
      "tags": ["xmpp","java","bioclipse","web"],
      
      
      
      
      
      
        "authors": [ { "name": "Egon Willighagen", "url": "https://orcid.org/0000-0001-7542-0286" } ]
      
    }

  ]
}
