<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ITworks &#187; web-service</title>
	<atom:link href="http://itworks.hu/tag/web-service/feed/" rel="self" type="application/rss+xml" />
	<link>http://itworks.hu</link>
	<description>Random musings in IT</description>
	<lastBuildDate>Mon, 09 Jan 2012 08:01:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Using JAX-WS without code generation</title>
		<link>http://itworks.hu/2008/08/05/using-jax-ws-without-code-generation/</link>
		<comments>http://itworks.hu/2008/08/05/using-jax-ws-without-code-generation/#comments</comments>
		<pubDate>Tue, 05 Aug 2008 21:58:41 +0000</pubDate>
		<dc:creator>csak</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[axis2]]></category>
		<category><![CDATA[Geronimo]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[JAX-WS]]></category>
		<category><![CDATA[web-service]]></category>
		<category><![CDATA[WebSphere]]></category>

		<guid isPermaLink="false">http://itworks.hu/?p=24</guid>
		<description><![CDATA[Something gave me the weird idea to try the new features of JAX-WS on a current project. The main idea was, to get rid of the code generators that must be ran whenever some minor change is done in the &#8230; <a href="http://itworks.hu/2008/08/05/using-jax-ws-without-code-generation/">Read more <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Something gave me the weird idea to try the new features of JAX-WS on a current project. The main idea was, to get rid of the code generators that must be ran whenever some minor change is done in the web service.</p>
<p>So instead of designing the WSDL along with the matching schema definition for the connector classes, I decided to start of by designing the interfaces and the connector classes, then just create the implementation with the corresponding annotations on the server side, that will be deployed automatically. The WSDL is generated from the annotations and the connector classes, there is no need to write them manually.</p>
<p><span id="more-24"></span>Take the following example. The web service has a simple method to query a list of items, that can throw a simple exception when the database is unreachable.</p>
<pre>import java.util.List;

import dummy.ws.type.Item;

public interface ItemService {
    public List&lt;Item&gt; getItemList() throws ItemException;
}</pre>
<p>with the implementation example like:</p>
<pre>import java.util.List;

import dummy.ws.type.Item;

import javax.jws.WebMethod;
import javax.jws.WebService;

@WebService(serviceName = "ItemService", targetNamespace = "http://dummy/ws", portName = "ItemPortType")
public class ItemServiceImpl implements ItemService {
    @WebMethod
    public List&lt;Item&gt; getItemList() throws ItemException {
        // <strong>TODO</strong> implementation comes here
    }
}</pre>
<p>can be invoked with the following simple code</p>
<pre>...
    Service service = Service.create(new URL(URLBASE
                     + "/ItemService?wsdl"), new QName(
                     "http://dummy/ws", "ItemService"));
    ItemService itemService = service.getPort(new QName(
                             "http://dummy/ws", "itemPortType"),
                             ItemService.class);
    List&lt;Item&gt; itemList = itemService.getItemList();
...</pre>
<p>There are several problems with this, even though it would be great to have it working right away. It could actually work, if there were no Collections involved on the return value. So creating a simple wrapper class for the return value like:</p>
<pre>package dummy.ws.types;</pre>
<pre>import java.util.List;

public class ItemList {</pre>
<pre>        private List&lt;Item&gt; content;
        public ItemList() {
        }</pre>
<pre>        public ItemList(List&lt;Item&gt; content) {
               this.content = content;
       }</pre>
<pre>        public List&lt;Item&gt; getContent() {
                return content;
        }

        public void setContent(List&lt;Item&gt; content) {
                this.content = content;
        }
}</pre>
<p>along with the modification of the interface and of course the implementation to use the newly created class should break the ice.</p>
<p>There is another shortcoming to this method yet. The thrown exception must contain a constructor with (String, Object) parameters, and an Object getFaultInfo method. Took me quite a time to figure it out, as there is a huge gap in the documentation when you try this. Once you&#8217;ve done that you are ready to deploy.</p>
<p>In the project we are using WebSphere Application Server Community Edition, which is an Apache Geronimo based quite stable and fast server. The WAS CE uses Axis2 for web service implementation. The rich client we implemented used the latest Axis2 libs.</p>
<p>The whole thing worked well until the middle of the project, when all of a sudden, without any major change that we could trace, the client suddenly started throwing JAXB exceptions (classname nor any of its super class is known to this context). This could only be cured by creating the jaxb.index in the ws.types package with all the connector classnames listed in it, along with an ObjectFactory that has a XXX createXXX () method for each ws.type class. Intrestingly however this class, while mandatory is never touched by the code, the class is not even loaded!</p>
<p>On the whole this approach provided a really quick and a bit dirty way of using the web services in a single project. However I would not dare to use it on a bigger scale. I still consider starting from the WSDL and the schema, then generating the interfaces and the connector classes from them the best approach.</p>
]]></content:encoded>
			<wfw:commentRss>http://itworks.hu/2008/08/05/using-jax-ws-without-code-generation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting up a project</title>
		<link>http://itworks.hu/2007/09/20/setting-up-a-project/</link>
		<comments>http://itworks.hu/2007/09/20/setting-up-a-project/#comments</comments>
		<pubDate>Thu, 20 Sep 2007 18:41:40 +0000</pubDate>
		<dc:creator>csak</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[axis]]></category>
		<category><![CDATA[continous-integration]]></category>
		<category><![CDATA[hibernate]]></category>
		<category><![CDATA[project]]></category>
		<category><![CDATA[swing]]></category>
		<category><![CDATA[web-service]]></category>

		<guid isPermaLink="false">http://itworks.hu/?p=19</guid>
		<description><![CDATA[I&#8217;ve been working for a major company as a lead developer for some time, and can&#8217;t fail to notice the trends of ignoring even the simplest and most basic &#8220;precautions&#8221; on any given project, whenever possible. Projects are always pushed &#8230; <a href="http://itworks.hu/2007/09/20/setting-up-a-project/">Read more <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been working for a major company as a lead developer for some time, and can&#8217;t fail to notice the trends of ignoring even the simplest and most basic &#8220;precautions&#8221; on any given project, whenever possible. Projects are always pushed for time either because it is really urgent, or more frequently, because it would cost more to have it hanging out for a bit longer. All the while I see software development trends focusing on quality, with continuous integration, iterative development, automated testing and so on, while all these great utilities are the first to be sacrificed when a project is &#8220;cost optimized&#8221;. The projects pass with flying colors and new people are hired for maintenance. These people are nowhere near the quality of a qualified developer, and screw things up until more experts are called in again to clean things up.</p>
<p><span id="more-19"></span>I know this is Hungary, but I very much fear this is also the case for most countries and most companies.</p>
<p>Take one of my last tasks as an example, I cannot be allocated for another project, but I was &#8220;borrowed&#8221; for a couple of days to set up a project environment for a very urgent and important job. The project was then handed over to two less then qualified developers. It was fun to set the project up, as the technologies I&#8217;ve chosen integrated nicely and resulted in an easy to maintain, compact environment. However I was forced to skip adding unit testing, as there was no way the project would fit writing a single test case.</p>
<p>Anyway I was going to write about the project itself and not mourn about the problems I can&#8217;t help.</p>
<p>The project is planned on simple grounds, there is a need for a GUI client, as a quite sophisticated editor is required. There is a need for small simple clients, so the the users would be able to use it with a relatively small configuration. The software delivery should be simple, so it would not burden the helpdesk. There is a need for security, as the application has some financial perspective to it. The project must be simple, so the not to advanced developers would be able to finish it. Ah yes, and I have two days to bang it together.</p>
<p>Well&#8230; Let&#8217;s start&#8230; The main constraint is the developers, they know some Hibernate, they know some Java, but know nothing about WSDL. Then the technology, to be easily deliverable it&#8217;s best to use Webstart, this will zero the deploy costs choosing Swing as the windowing environment enables the developers to use visual editors to bang some forms together, while reduces the deployment size greatly, if we consider the SWT alternative. The application will communicate with the server through web service through SSL to ensure security.</p>
<p>I have thus set up a project which contains both the client and the server code and the common codebase as well (the interfaces and POJOs used in web services), there is an ANT script to generate the WSDL, the code for Axis based web service classes, and the Hibernate POJO, and DAO-s. The generated code is stored in it&#8217;s respective folders, separated from the handwritten code. The ANT script is then compiles the files and it is also able to create the WAR and deploy on either Tomcat or WebSphere Application Server.  The project is set up in an Anthill to ensure that at least the developers are notified if their committed code breaks the application.</p>
<p>Even though I&#8217;ve created this environment as simple as humanly possible, when I handled it over to the developers-to-be they were less than understandig.</p>
<p>I can only hope they don&#8217;t mess it up too bad.</p>
]]></content:encoded>
			<wfw:commentRss>http://itworks.hu/2007/09/20/setting-up-a-project/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

