<?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>JavaBeat &#187; Webservices</title>
	<atom:link href="http://www.javabeat.net/category/xml-web-services/webservices/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.javabeat.net</link>
	<description>Java Technology News</description>
	<lastBuildDate>Mon, 13 May 2013 20:10:23 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Java ME and Web services</title>
		<link>http://www.javabeat.net/2011/03/java-me-and-web-services/</link>
		<comments>http://www.javabeat.net/2011/03/java-me-and-web-services/#comments</comments>
		<pubDate>Thu, 31 Mar 2011 13:45:14 +0000</pubDate>
		<dc:creator>krishnas</dc:creator>
				<category><![CDATA[J2ME]]></category>
		<category><![CDATA[Webservices]]></category>
		<category><![CDATA[WebServices]]></category>

		<guid isPermaLink="false">http://www.javabeat.net/?p=607</guid>
		<description><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><p>Introduction Java Micro Edition (Java ME) is a platform for running applications on smaller devices such as mobile phones, PDAs etc. These devices have restrictions in terms of Memory and Processing power. Java ME defines various configurations and profiles. Midlets are java applications that operate on Mobile Information Device Profile (MIDP) which is targeted on [...]</p>]]></description>
				<content:encoded><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><div class="wpInsert wpInsertInPostAd wpInsertLeft" style="float: left; margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Rect */
google_ad_slot = "9976259118";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><a id="dd_start"></a><h2>Introduction</h2>
<p>Java Micro Edition (Java ME) is a platform for running applications on smaller devices such as mobile phones, PDAs etc. These devices have restrictions in terms of Memory and Processing power. Java ME defines various configurations and profiles. Midlets are java applications that operate on Mobile Information Device Profile (MIDP) which is targeted on Mobile phones that has limited memory and processing power. If you are new to Java ME please refer to the articles <strong><a href="http://www.javabeat.net/articles/27-introduction-to-j2me-1.html">Introduction to J2ME</a></strong> and <strong><a href="http://www.javabeat.net/articles/45-j2me-user-interface-1.html">J2ME User Interface</a></strong> in Java Beat.</p>
<p>Due to the limitations on the mobile phones, the midlets can’t be exposed as a web service. But the midlets can consume web services. Java ME provides a subset of JAX-RPC APIs to work with web services. This article will provide a step by step procedure to access web services from a midlet.</p>
<h2>Invoking web services from a Midlet</h2>
<p>To access web services, the Midlet has to make remote calls on the web services. But the Midlets won’t do this directly. A stub has to be created and calls are made via the stub instance. Using wireless toolkit it is made very simple to create stub code. Invocation on web service method is a synchrous process. The parameters for the methods are passes by value instead of pass by references. Similarly the values are returned by web services as pass by value. On the stubs midlets can set some properties like USERNAME_PROPERTY, PASSWORD_PROPERTY (User name and password for authentication), ENDPOINT_ADDRESS_PROPERTY(Address of the endpoint) and SESSION_MAINTAIN_PROPERTY(if true:session will be maintained between endpoint and midlet) using _setProperty method.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">stub._setProperty(Stub.ENDPOINT_ADDRESS_PROPERTY,serviceUrl);
	stub._setProperty(Stub.SESSION_MAINTAIN_PROPERTY, new Boolean(true));</pre></td></tr></table></div>

<p>The generated stub code and the supportive classes have to be bundled in the jar file along with the midlet. While accessing web services the best practice is to write the sub invocation code in a seperate thread. This will avoid your application hanging as your thread will be blocked during web service invocation.</p>
<h2>Example</h2>
<p>This example will help you in understanding how to access web service from a midlet. Netbeans IDE, Glassfish application server and Wireless tool kit 2.5.2 are used.</p>
<h3>Create the web service and deploy it in the application server</h3>
<p><span style="text-decoration: underline;">Web service:</span></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">package mypack;
	import javax.jws.WebMethod;
	import javax.jws.WebParam;
	import javax.jws.WebService;
	@WebService()
	public class HelloService {
		@WebMethod(operationName = &quot;getMessage&quot;)
		public String getMessage(@WebParam(name = &quot;name&quot;)
		String name) {
			return &quot;Hi &quot;+name+&quot;! Welcome to JME Programming&quot;;
		}
	}</pre></td></tr></table></div>

<p><span style="text-decoration: underline;">WSDL URL:</span></p>
<p>http://localhost:17754/HelloWebService/HelloServiceService?WSDL</p>
<h3>Create a Midlet with a form with a text field and command buttons.</h3>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">public class Midlet extends MIDlet implements CommandListener{
		private Form myform;
		private TextField field;
		private Command exit,getMessage;
		private Display d;
		public void startApp() {
			d=Display.getDisplay(this);
			myform=new Form(&quot;Access Webservice&quot;);
			field=new TextField(&quot;Name&quot;, &quot;&quot;, 20, TextField.PLAIN);
			exit=new Command(&quot;Exit&quot;, Command.EXIT, 0);
			getMessage=new Command(&quot;GetMsg&quot;, Command.SCREEN, 1);
			myform.append(field);
			myform.addCommand(exit);
			myform.addCommand(getMessage);
			myform.setCommandListener(this);
			d.setCurrent(myform);
		}
		public void pauseApp() {
		}
		public void destroyApp(boolean unconditional) {
		}
		public void commandAction(Command c, Displayable d) {
			if(c==exit){
				notifyDestroyed();
			}else if(c==getMessage){
				//Code to Access Webservice
			}
		}
	}</pre></td></tr></table></div>

<h3>Use Wireless tool kit tool to create the stub</h3>
<p><a href="http://www.javabeat.net/wp-content/uploads/2011/03/113.jpg"><img class="aligncenter size-medium wp-image-1110" title="1" src="http://www.javabeat.net/wp-content/uploads/2011/03/113-300x168.jpg" alt="" width="300" height="168" /></a>a) Open Wireless Toolkit</p>
<p><center></center><a href="http://www.javabeat.net/wp-content/uploads/2011/03/210.jpg"><img class="aligncenter size-medium wp-image-1111" title="2" src="http://www.javabeat.net/wp-content/uploads/2011/03/210-300x167.jpg" alt="" width="300" height="167" /></a></p>
<p>(b) Select File -&gt; Utilities</p><div class="wpInsert wpInsertInPostAd wpInsertMiddle" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Middle-Med-Rect */
google_ad_slot = "7805667846";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
<p><a href="http://www.javabeat.net/wp-content/uploads/2011/03/35.jpg"><img class="aligncenter size-medium wp-image-1307" title="3" src="http://www.javabeat.net/wp-content/uploads/2011/03/35-300x256.jpg" alt="" width="300" height="256" /></a></p>
<p><center></center>(c) Select Stub Generator</p>
<p><a href="http://www.javabeat.net/wp-content/uploads/2011/03/45.jpg"><img class="aligncenter size-medium wp-image-1306" title="4" src="http://www.javabeat.net/wp-content/uploads/2011/03/45-279x300.jpg" alt="" width="279" height="300" /></a></p>
<p><center></center>d) Provide WSDL URL and the Output folder(src folder in Netbeans project) and the package details. Click on Ok</p>
<p><a href="http://www.javabeat.net/wp-content/uploads/2011/03/52.jpg"><img class="aligncenter size-medium wp-image-1108" title="5" src="http://www.javabeat.net/wp-content/uploads/2011/03/52-300x210.jpg" alt="" width="300" height="210" /></a></p>
<p><center></center>(e) The Stub and the other classes are generated in the src folder</p>
<h3>Access Web service</h3>
<p>For accessing web service,</p>
<ol>
<li>Create a new thread.</li>
<li>In the new thread, Instantiate the stub</li>
<li>Set properties on the stub if required</li>
<li>Invoke the web service methods on the stub</li>
</ol>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">//Extend the code written earlier
	import mypack.HelloService_Stub;
	public class Midlet extends MIDlet implements CommandListener{
		private Form myform;
		private TextField field;
		private Command exit,getMessage;
		private Display d;
		public TextField getField() {
			return field;
		}
		public Form getMyform() {
			return myform;
		}
		....
		public void commandAction(Command c, Displayable d) {
			if(c==exit){
				notifyDestroyed();
			}else if(c==getMessage){
				Thread t=new Thread(new NewThread(this));
				t.start();
			}
		}
	}	
	class NewThread implements Runnable{
		Midlet m;
		NewThread(Midlet m){
			this.m=m;
		}
		public void run() {
			Form frm=m.getMyform();
			TextField txt=m.getField();
			HelloService_Stub stub=new HelloService_Stub();
			String msg=&quot;&quot;;
			try {
				msg = stub.getMessage(txt.getString());
				frm.append(msg);
			} catch (RemoteException ex) {
				frm.append(ex.getMessage());
			}
		}
	}</pre></td></tr></table></div>

<h3>Run the Midlet</h3>
<p>Run the midlet. Provide the Name and select the command button GetMsg. The following output will be displayed.</p>
<p><a href="http://www.javabeat.net/wp-content/uploads/2011/03/6.jpg"><img class="aligncenter size-medium wp-image-1308" title="6" src="http://www.javabeat.net/wp-content/uploads/2011/03/6-147x300.jpg" alt="" width="147" height="300" /></a></p>
<h2>Conclusion</h2>
<p>Java ME Midlets can act only as the consumer for web services. It can’t be exposed as a web service. Wireless Tool Kit helps in creating stubs for web services. Midlets by invoking methods on the stub invokes methods on web services. Both simple types and complex types can be passed as parameters to the web services.</p>
<div class='dd_outer'><div class='dd_inner'><div id='dd_ajax_float'><div class='dd_button_v'><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="http%3A%2F%2Fwww.javabeat.net%2Fcategory%2Fxml-web-services%2Fwebservices%2Ffeed%2F" send="false" show_faces="false"  layout="box_count" width="50"  ></fb:like></div><div style='clear:left'></div><div class='dd_button_v'><script type='text/javascript' src='https://apis.google.com/js/plusone.js'></script><g:plusone size='tall' href='http://www.javabeat.net/category/xml-web-services/webservices/feed/'></g:plusone></div><div style='clear:left'></div><div class='dd_button_v'><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.javabeat.net/category/xml-web-services/webservices/feed/" data-count="vertical" data-text="Webservices" data-via="javabeat" ></a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div><div style='clear:left'></div><div class='dd_button_extra_v'><script type="text/javascript">jQuery(document).load(function(){ stLight.options({publisher:'bab47279-62c9-46af-addc-79fd1fe8fee0'}); });</script><div class="st_email_custom"><span id='dd_email_text'>email</span></div></div><div style='clear:left'></div><div class='dd_button_extra_v'><div id='dd_print_button'><span id='dd_print_text'><a href='javascript:window:print()'>print</a></span></div></div><div style='clear:left'></div></div></div></div><script type="text/javascript">var dd_offset_from_content = 44; var dd_top_offset_from_content = 0;</script><script type="text/javascript" src="http://www.javabeat.net/wp-content/plugins/digg-digg//js/diggdigg-floating-bar.js?ver=5.3.0"></script><div class="wpInsert wpInsertInPostAd wpInsertBelow" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* JB-Footer-LU 468x15 */
google_ad_slot = "8789107210";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>]]></content:encoded>
			<wfw:commentRss>http://www.javabeat.net/2011/03/java-me-and-web-services/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apache Axis2 Web Services</title>
		<link>http://www.javabeat.net/2011/03/apache-axis2-web-services/</link>
		<comments>http://www.javabeat.net/2011/03/apache-axis2-web-services/#comments</comments>
		<pubDate>Fri, 11 Mar 2011 15:34:20 +0000</pubDate>
		<dc:creator>krishnas</dc:creator>
				<category><![CDATA[Webservices]]></category>

		<guid isPermaLink="false">http://www.javabeat.net/?p=1482</guid>
		<description><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><p>&#160; SOA, in practicality web services, is becoming the enabler for application integration. Since the introduction of web services, Apache Software Foundation has played a major role and produced several good web services frameworks. This book covers the defector Java Web Service framework, also known as Apache Axis2. This book covers several important facts that [...]</p>]]></description>
				<content:encoded><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><div class="wpInsert wpInsertInPostAd wpInsertLeft" style="float: left; margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Rect */
google_ad_slot = "9976259118";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><p>&nbsp;</p>
<p>SOA, in practicality web services, is becoming the enabler for application integration. Since the introduction of web services, Apache Software Foundation has played a major role and produced several good web services frameworks. This book covers the defector Java Web Service framework, also known as Apache Axis2. This book covers several important facts that you would want to know about web services and writing, from simple web services to complex web services. By the end of this book, you will have learned about Axis2, its architectures and features, writing and deploying a simple service, writing service extensions and quality of services, POJO and JAX-WS services, clusters, and secure reliable web services.</p>
<h1>What This Book Covers</h1>
<p><em>Chapter 1, Apache Web Services and Axis2</em> &#8211; Gives you an introduction to web services and the web service stack at Apache.</p>
<p><em>Chapter 2, Looking inside Axis2</em> &#8211; Learn about Axis2 architecture and the importance of its components.</p>
<p><em>Chapter 3, Axis2 XML Model (AXIOM)</em> &#8211; Learn about the heart of a web service framework and learning more about XML processing in Axis2.</p>
<p><em>Chapter 4, Execution Chain</em> &#8211; Learn how to extend the core functionality of the<br />
framework though handlers.</p>
<p><em>Chapter 5, Deployment Mode</em> &#8211; Learn about the new and user friendly deployment model and several ways of deploying a service in Axis2.</p>
<p><em>Chapter 6, Information Model</em> &#8211; Learn how Axis2 stores it static and dynamic data and the importance of it.</p>
<p><em>Chapter 7, Writing an Axis2 Service</em> &#8211; Learn how to write a simple-complex service using Axis2 and how to deploy it</p>
<p><em>Chapter 8, Writing an Axis2 Module</em> &#8211; Learn how to extend Axis2 core functionality<br />
through a self-contained package.</p>
<p><em>Chapter 9, The Client API</em> &#8211; Learn how to use Axis2 to invoke other services, available APIs, and how to use them.</p>
<p><em>Chapter 10, Session Management</em> &#8211; Go beyond single invocation and learn how to use Axis2 features to provide better and more efficient statefull service.</p>
<p><em>Chapter 11, Developing JAX-WS Web Services</em> &#8211; Learn the fundamentals of developing JAXWS based web services, the most popular web service development technology used by Java developers.</p>
<p><em>Chapter 12, Axis2 Clustering</em> &#8211; Learn about clustering Apache Axis2, which will allow<br />
you to deploy Axis2 in large scale production deployments.</p>
<p><em>Chapter 13, Enterprise Integration Patterns</em> &#8211; Learn about some enterprise SOA deployment patterns that make use of the underlying Axis2 clustering infrastructure.</p>
<p><em>Chapter 14, Axis2 Advanced Features and Usage</em> &#8211; Go beyond simple features and learn about REST, MTOM, and several other advanced features.</p>
<p><em>Chapter 15, Building a Secure Reliable Web Service</em> &#8211; Learn how to use Axis2 and<br />
related components to make your service more secure and reliableWriting an Axis2 Module Web services are gaining a lot of popularity in the industry and have become one of the major enabler for application integration. In addition, due to the fl exibility and advantages of using web services, everyone is trying to enable web service support for their applications. As a result, web service frameworks need to support new and more custom requirements. As we have already discussed in the previous chapters, one of the major goals of a web service framework is to deliver incoming messages into the target service. However, just delivering the message to the service is not enough; today&#8217;s applications are required to have reliability, security, transaction, and other quality services.</p>
<p>Due to the popularity of web services, standard bodies are producing new web service standards, and it is hard to support those new standards if the web service framework is not fl exible enough. From the very beginnings of Axis2, fl exibility and extensibility were the two main design considerations. The idea of Axis2 modules is to extend the core functionality of the system without performing any changes to the core system.<br />
For example, Axis2 supports reliability and security as two separate modules, and the core engine is fully independent of those two qualities of service modules.</p>
<p>In this chapter, we will discuss the power of Axis2 modules and how to use them to<br />
extend Axis2 to support for your own requirements. In particular, we will discuss<br />
the following items:</p>
<ul>
<li>Brief history of the Axis2 module</li>
<li>Introducing module concept</li>
<li>Structure of the module</li>
<li>Module configuration file (module.xml)</li>
<li>Optional module implementation class</li>
<li>Steps to writing a module.xml file</li>
<li>Deploying and engaging a module</li>
<li>Brief overview of the WS-Policy and its usage in modules</li>
</ul>
<p>In our approach, we will be using code sample to help us understand the concepts better.</p>
<h2>Brief history of the Axis2 module</h2>
<p>Looking back at the history of Apache Web Services, the Handler concept can be considered as one of the most useful and interesting ideas. Due to the importance and fl exibility of the handler concept, Axis2 has also introduced it into its architecture. Notably, there are some major differences in the way you deploy handlers in Axis1 and Axis2. In Axis1, adding a handler requires you to perform global configuration changes and for an end user, this process may become a little complex. In contrast, Axis2 provides an easy way to deploy handlers. Moreover, in Axis2, deploying a handler is similar to deploying a service and does not require global configuration changes.</p>
<p>At the design stage of Axis2, one of the key considerations was to have a mechanism<br />
to extend the core functionality without doing much. One of the main reasons behind the design decision was due to the lesson learned from supporting WS reliable messaging in Axis1. The process of supporting reliable messaging in Axis1 involved a considerable amount of work, and part of the reason behind the complex process was due to the limited extensibility of Axis1 architecture. Therefore, learning from a session in Axis1, Axis2 introduced a very convenient and fl exible way of extending the core functionality and providing the quality of services. This particular mechanism is known as the module concept.</p>
<h2>Module concept</h2>
<p>In <em>Chapter 4, Execution Chain</em>, we introduced and discussed the handler concepts and how to use handlers. As we discussed there, one of the main ideas behind a handler is to intercept the message fl ow and execute specific logic. In Axis2, the concept of a module is to provide a very convenient way of deploying service extension. We can also consider a <strong>module</strong> as a collection of handlers and required resources to run the handlers (for example, third-party libraries). One can also consider a module as an implementation of a web service standard specification. As an illustration, Apache Sandesha is an implementation of WS-RM specification. Apache Rampart is an implementation of WS-security; likewise, in a general module, is an implementation of a web service specification. One of the most important features and aspects of the Axis2 module is that it provides a very easy way to extend the core functionality and provide better customization of the framework to suit complex business requirements. A simple example would be to write a module to log all the incoming messages or to count the number of messages, if requested.</p><div class="wpInsert wpInsertInPostAd wpInsertMiddle" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Middle-Med-Rect */
google_ad_slot = "7805667846";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
<h2>Module structure</h2>
<p>As mentioned a few times before in previous chapters, Axis1 is one of the most<br />
popular web service frameworks and it provides very good support for most of the<br />
web service standards. However, when it comes to new and complex specifications,<br />
there is a significant amount of work we need to do to achieve our goals. The problem becomes further complicated when the work we are going to do involves handlers, configuration, and third-party libraries. To overcome this issue, the Axis2 module concept and its structure can be considered as a good candidate. As we discussed in the deployment section, both Axis2 services and modules can be deployed as archive files. Inside any archive file, we can have configuration files, resources, and the other things that the module author would like to have.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">It should be noted here that we have hot deployment and hot update
	support for the service; in other words, you can add a service when the
	system is up and running. However, unfortunately, we cannot deploy
	new modules when the system is running. You can still deploy modules,
	but Axis2 will not make the changes to the runtime system (we can drop
	them into the directory but Axis2 will not recognize that), so we will
	not use hot deployment or hot update. The main reason behind this is
	that unlike services, modules tend to change the system configurations,
	so performing system changes at the runtime to an enterprise-level
	application cannot be considered a good thing at all.</pre></td></tr></table></div>

<p>As we discussed earlier, adding a handler into Axis1 involves global configuration<br />
changes and, obviously, system restart. In contrast, when it comes to Axis2, we can add handlers using modules without doing any global level changes. There are instances where you need to do global configuration changes, which is a very rare situation and you only need to do so if you are trying to add new phases and change the phase orders. You can change the handler chain at the runtime without downer-starting the system.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">As mentioned earlier, changing the handler chain or any global
	configuration at the runtime cannot be considered a good habit. This is
	because in a production environment, changing runtime data may affect
	the whole system. However, at the deployment and testing time this
	comes in handy.</pre></td></tr></table></div>

<p>The structure of a module archive file is almost identical to that of a service archive<br />
file, except for the name of the configuration file. We know that for a service archive<br />
file to be a valid one, it is required to have a services.xml. In the same way, for a module to be a valid module archive, it has to have a module.xml file inside the META-INF directory of the archive. A typical module archive file will take the structure shown in the following screenshot. We will discuss each of the items in detail and create our own module in this chapter as well.</p>
<p>&nbsp;</p>
<p><a href="http://www.javabeat.net/wp-content/uploads/2012/04/11.jpg"><img class="aligncenter size-medium wp-image-1485" title="1" src="http://www.javabeat.net/wp-content/uploads/2012/04/11-300x296.jpg" alt="" width="300" height="296" /></a></p>
<p>&nbsp;</p>
<h2>Module configuration file (module.xml)</h2>
<p>As we have already discussed, the module archive file is a self-contained and<br />
self-described file. In other words, it has to have all the configuration required to<br />
be a valid and useful module. Needless to say, that is the beauty of a self-contained<br />
package. The Module configuration file or module.xml file is the configuration file<br />
that Axis2 can understand to do the necessary work.</p>
<p>A simple module.xml file has one or more handlers. In contrast, when it comes to<br />
complex modules, we can have some other configurations (for example, WS policies,<br />
phase rules) in a module.xml. First, let&#8217;s look at the available types of configurations<br />
in a module.xml. For our analysis, we will use a module.xml of a module that counts<br />
all the incoming and outgoing messages. We will be discussing all the important<br />
items in detail and provide a brief description for the other items:</p>
<ul>
<li>Handlers alone with phase rules</li>
<li>Parameters</li>
<li>Description about module</li>
<li>Module implementation class</li>
<li>WS-Policy</li>
<li>End points</li>
</ul>
<h2>Handlers and phase rules</h2>
<p>As we discussed, a module is a collection of handlers, so a module could have one<br />
or more handlers. Irrespective of the number of handlers in a module, module.<br />
xml provides a convenient way to specify handlers. Most importantly, module.<br />
xml can be used to provide enough configuration options to add a handler into the<br />
system and specify the exact location where the module author would like to see the<br />
handler running. In <em>Chapter 4, Execution Chain</em>, we learnt more about phase rules as<br />
a mechanism to tell Axis2 to put handlers into a particular location in the execution<br />
chain, so now it is time to look at them with an example.</p>
<p>Before learning how to write phase rules and specifying handlers in a module.xml,<br />
let&#8217;s look at how to write a handler. There are two ways to write a handler in Axis2:</p>
<ul>
<li>Implement the org.apache.axis2.engine.Handler interface</li>
<li>Extend the org.apache.axis2.handlers.AbstractHandler abstract class</li>
</ul>
<p>In this chapter, we are going to write a simple application to provide a better<br />
understanding of the module. Furthermore, to make the sample application easier,<br />
we are going to ignore some of the difficulties of the Handler API. In our approach,<br />
we will extend the AbstractHandler. When we extend the abstract class, we only<br />
need to implement one method called invoke. So the following sample code will<br />
illustrate how to implement the invoke method:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">public class IncomingCounterHandler extends AbstractHandler implements
	CounterConstants {
		public InvocationResponse invoke(MessageContext messageContext) throws
		AxisFault {
			//get the counter property from the configuration context
			ConfigurationContext configurationContext = messageContext.
				getConfigurationContext();
			Integer count =
				(Integer) configurationContext.getProperty(INCOMING_
				MESSAGE_COUNT_KEY);
			//increment the counter
			count = Integer.valueOf(count.intValue() + 1 + «»);
			//set the new count back to the configuration context
			configurationContext.setProperty(INCOMING_MESSAGE_COUNT_KEY,
				count);
			//print it out
			System.out.println(«The incoming message count is now « +
				count);
			return InvocationResponse.CONTINUE;
		}
	}</pre></td></tr></table></div>

<p>As we can see, the method takes MessageContext as a method parameter and returns InvocationResponse as the response. You can implement the method as follows:</p>
<ol>
<li>First get the configurationContext from the messageContext.</li>
<li>Get the property value specified by the property name.</li>
<li>Then increase the value by one.</li>
<li>Next set it back to configurationContext.</li>
<li>In general, inside the invoke method, as a module author, you have to do<br />
all the logic processing, and depending on the result you get, we can decide<br />
whether you let AxisEngine continue, suspend, or abort. Depending on your<br />
decision, you can return to one of the three following allowed return types:</li>
<ul>
<li>InvocationResponse.CONTINUEGive the signal to continue the message</li>
<li>InvocationResponse.SUSPENDThe message cannot continue as some of the conditions are not<br />
satisfied yet, so you need to pause the execution and wait.</li>
<li>InvocationResponse.ABORTSomething has gone wrong, therefore you need to drop the message<br />
and let the initiator know about it</li>
</ul>
<li>The message cannot continue as some of the conditions are not satisfied yet,<br />
so you need to pause the execution and wait.</li>
<li>InvocationResponse.ABORT.</li>
<li>Something has gone wrong, therefore you need to drop the message and let<br />
the initiator know about it.</li>
</ol>
<p>The corresponding CounterConstants class a just a collection of constants and will<br />
look as follows:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">public interface CounterConstants {
		String INCOMING_MESSAGE_COUNT_KEY = &quot;incoming-message-count&quot;;
		String OUTGOING_MESSAGE_COUNT_KEY = &quot;outgoing-message-count&quot;;
		String COUNT_FILE_NAME_PREFIX = &quot;count_record&quot;;
	}</pre></td></tr></table></div>

<p>As we already mentioned, the sample module we are going to implement is for counting the number of request coming into the system and the number of messages<br />
going out from the system. So far, we have only written the incoming message counter and we need to write the outgoing message counter as well, and the implementation of the out message count hander will look like the following:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">public class OutgoingCounterHandler extends AbstractHandler implements
	CounterConstants {
		public InvocationResponse invoke(MessageContext messageContext)
		throws AxisFault {
			//get the counter property from the configuration context
			ConfigurationContext configurationContext = messageContext.
				getConfigurationContext();
			Integer count =
				(Integer) configurationContext.getProperty(OUTGOING_
				MESSAGE_COUNT_KEY);
			//increment the counter
			count = Integer.valueOf(count.intValue() + 1 + «»);
			//set it back to the configuration
			configurationContext.setProperty(OUTGOING_MESSAGE_COUNT_KEY,
				count);
			//print it out
			System.out.println(«The outgoing message count is now « +
				count);
			return InvocationResponse.CONTINUE;
		}
	}</pre></td></tr></table></div>

<p>The implementation logic will be exactly the same as the incoming handler processing, except for the property name used in two places.</p>
<h2>Module implementation class</h2>
<p>When we work with enterprise-level applications, it is obvious that we have to initialize various settings such as database connections, thread pools, reading property, and so on. Therefore, you should have a place to put that logic in your module. We know that handlers run only when a request comes into the system but not at the system initialization time. The module implementation class provides a way to achieve system initialization logic as well as system shutdown time processing. As we mentioned earlier, module implementation class is optional. A<br />
very good example of a module that does not have a module implementation class is the Axis2 addressing module. However, to understand the concept clearly in our example application, we will implement a module implementation class, as shown below:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">public class CounterModule implements Module, CounterConstants {
		private static final String COUNTS_COMMENT = &quot;Counts&quot;;
		private static final String TIMESTAMP_FORMAT = &quot;yyMMddHHmmss&quot;;
		private static final String FILE_SUFFIX = &quot;.properties&quot;;
		public void init(ConfigurationContext configurationContext,
		AxisModule axisModule) throws AxisFault {
			//initialize our counters
			System.out.println(&quot;inside the init : module&quot;);
			initCounter(configurationContext, INCOMING_MESSAGE_COUNT_KEY);
			initCounter(configurationContext, OUTGOING_MESSAGE_COUNT_KEY);
		}
		private void initCounter(ConfigurationContext
			configurationContext,
			String key) {
			Integer count = (Integer) configurationContext.
				getProperty(key);
			if (count == null) {
				configurationContext.setProperty(key, Integer.
					valueOf(&quot;0&quot;));
			}
		}
		public void engageNotify(AxisDescription axisDescription) throws
			AxisFault {
			System.out.println(&quot;inside the engageNotify &quot; +
				axisDescription);
		}
		public boolean canSupportAssertion(Assertion assertion) {
			//returns whether policy assertions can be supported
			return false;
		}
		public void applyPolicy(Policy policy,
			AxisDescription axisDescription) throws
			AxisFault {
			// Configuure using the passed in policy!
		}
		public void shutdown(ConfigurationContext configurationContext)
			throws AxisFault {
			//do cleanup - in this case we'll write the values of the
			counters to a file
			try {
				SimpleDateFormat format = new SimpleDateFormat(TIMESTAMP_
					FORMAT);
				File countFile = new File(COUNT_FILE_NAME_PREFIX + format.
					format(new Date()) + FILE_SUFFIX);
				if (!countFile.exists()) {
					countFile.createNewFile();
				}
				Properties props = new Properties();
				props.setProperty(INCOMING_MESSAGE_COUNT_KEY,
					configurationContext.getProperty(INCOMING_MESSAGE_
					COUNT_KEY).toString());
				props.setProperty(OUTGOING_MESSAGE_COUNT_KEY,
					configurationContext.getProperty(OUTGOING_MESSAGE_
				COUNT_KEY).toString());
				//write to a file
				props.store(new FileOutputStream(countFile), COUNTS_
					COMMENT);
			} catch (IOException e) {
				//if we have exceptions we'll just print a message and let
				it go
				System.out.println(&quot;Saving counts failed! Error is &quot; +
					e.getMessage());
			}
		}
	}</pre></td></tr></table></div>

<p>As we can see, there are a number of methods in the previous module implementation class. However, notably not all of them are in the module interface.<br />
The module interface has only the following methods, but here we have some other<br />
methods for supporting our counter module-related stuff:</p>
<ul>
<li>init</li>
<li>engageNotify</li>
<li>applyPolicy</li>
<li>shutdown</li>
</ul>
<p>At the system startup time, the init method will be called, and at that time, the module can perform various initialization tasks. In our sample module, we have initialized both in-counter and out-counter.</p>
<p>When we engage this particular module to the whole system, to a service, or to an<br />
operation, the engagNotify method will be called. At that time, a module can decide whether the module can allow this engagement or not; say for an example, we try to engage the security module to a service, and at that time, the module finds out that there is a confl ict in the encryption algorithm. In this case, the module will not be able to engage and the module throws an exception and Axis2 will not engage the module. In this example, we will do nothing inside the engageNotify method.</p>
<p>As you might already know, WS-policy is one of the key standards and plays a major<br />
role in the web service configuration. When you engage a particular module to a service, the module policy should be applied to the service and should be visible when we view the WSDL of that service. So the applyPolicy method sets the module policy to corresponding services or operations when we engage the module.<br />
In this particular example, we do not have any policy associated with the module, so<br />
we do not need to worry about this method as well.</p>
<p>As we discussed in the init method, the method shutdown will be called when the system has to shut down. So if we want to do any kind of processing at that time, we can add this logic into that particular method. In our example, for demonstration<br />
purposes, we have added code to store the counter values in a file.</p>
<h2>Webservices Articles &amp; Books</h2>
<ul>
<li><a href="http://www.javabeat.net/articles/webservice/1/">Webservices Articles</a></li>
<li><a href="http://www.javabeat.net/books/webservice/1/">Webservices Books</a></li>
<li><a href="http://www.javabeat.net/articles/57-accessing-web-services-from-jsf-applications-1.html">Accessing Web Services from JSF applications</a></li>
<li><a href="http://www.javabeat.net/articles/40-creating-webservice-using-jboss-and-eclipse-europa-1.html">Creating Webservice using JBoss and Eclipse Europa</a></li>
<li><a href="http://www.javabeat.net/articles/36-juddi-and-configuration-in-jboss-and-mysql-database-1.html">jUDDI and Configuration in jBoss and MySQL database</a></li>
</ul>
<div class="wpInsert wpInsertInPostAd wpInsertBelow" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* JB-Footer-LU 468x15 */
google_ad_slot = "8789107210";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>]]></content:encoded>
			<wfw:commentRss>http://www.javabeat.net/2011/03/apache-axis2-web-services/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Developing a Web Service with CXF</title>
		<link>http://www.javabeat.net/2010/07/developing-a-web-service-with-cxf/</link>
		<comments>http://www.javabeat.net/2010/07/developing-a-web-service-with-cxf/#comments</comments>
		<pubDate>Fri, 23 Jul 2010 23:55:33 +0000</pubDate>
		<dc:creator>krishnas</dc:creator>
				<category><![CDATA[Webservices]]></category>

		<guid isPermaLink="false">http://www.javabeat.net/?p=1815</guid>
		<description><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><p>Apache CXF Web Service Development Apache CXF is an open source services framework that makes web service development easy, simplified, and standard based. CXF provides many features such as frontend programming, support for different transports and data bindings, support for different protocols, and other advanced concepts like Features and Invokers. It also provides a programming [...]</p>]]></description>
				<content:encoded><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><div class="wpInsert wpInsertInPostAd wpInsertLeft" style="float: left; margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Rect */
google_ad_slot = "9976259118";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><p><H1><CENTER>Apache CXF Web Service Development</CENTER></H1><br />
<P>Apache CXF is an open source services framework that makes web service development<br />
easy, simplified, and standard based. CXF provides many features such as frontend<br />
programming, support for different transports and data bindings, support for different<br />
protocols, and other advanced concepts like Features and Invokers. It also provides a<br />
programming model to build and deploy RESTful services.</P><br />
<P>The focus of the book is to provide readers with comprehensive details on how to use the<br />
overview of CXF features and architecture. Each feature is explained in a separate<br />
chapter, each of which covers well defined practical illustrations using real world<br />
examples. This helps developers to easily understand the CXF API. Each chapter<br />
provides hands on examples and provides step-by-step instructions to develop, deploy,<br />
and execute the code.</P><br />
<H1>What This Book Covers</H1><br />
<P>The book is about the CXF service development framework. The book covers two of the<br />
most widely used approaches, for web services development, SOAP and REST. Each<br />
chapter in the book provides hands on examples, where we look in detail at how to use<br />
the various CXF features in detail to develop web services in a step-by-step fashion</P><br />
<P>Chapter 1: <I>Getting Familiar with CXF</I> revisits web service concepts and provides an<br />
introduction to CXF framework and its usage, and prepares the CXF environment for the<br />
following chapters. By the end of this chapter the reader will be able to understand the<br />
core concepts of CXF.</P><br />
<P>Chapter 2: <I>Developing a Web Service with CXF</I> focuses on getting the reader quickly<br />
started with the CXF framework by developing a simple web service and running it under<br />
the Tomcat container.</P><br />
<P>By the end of this chapter the reader will be able to develop a simple web service<br />
using CXF.</P><br />
<P>Chapter 3: <I>Working with CXF Frontends</I> illustrates the use of different frontends, like<br />
JAX-WS and CXF simple fronted API, and shows how to apply code-first and contractfirst<br />
development approaches for developing web services. We will look at how to create<br />
dynamic web service clients, the use of web service context, and how to work directly<br />
with XML messages using CXF Provide and Dispatch implementation.</P><br />
<P>By the end of this chapter the reader will be able to apply different frontends to develop a<br />
web service.</P><br />
<P>Chapter 4: <I>Learning about Service Transports</I> explains basic transport protocols for a<br />
service and shows you how to configure HTTP, HTTP(s), JMS, and Local protocol for<br />
web services communication. You will get introduced to the concept of HTTP conduit,<br />
which enables the client program to apply policies or properties to HTTP and HTTPs<br />
protocols, and how to generate a crypto key and a key store for HTTPs based service<br />
communication. You will learn how to use JMS protocol for web services<br />
communication and how to facilitate web services message exchange using CXF Local<br />
service transport.</P><br />
<P>By the end of this chapter the reader will be able develop services with<br />
different transports</P><br />
<P>Chapter 5: <I>Implementing Advanced Features</I> will explain advanced concepts using CXF<br />
Features, Interceptors, and Invokers, and how to integrate these concepts in existing<br />
applications.</P><br />
<P>By the end of this chapter the reader will be able develop services with features like<br />
Interceptors and Invokers</P><br />
<P>Chapter 6: <I>Developing RESTful Services with CXF</I> explains the concept of REST<br />
demonstrates additional features for developing enterprise RESTful services. We will<br />
look at how to design, develop, and unit test the RESTful Service by taking a real world<br />
example using CXF JAX-RS implementation.</P><br />
<P>By the end of this chapter the reader will be able to design, develop, and unit test the<br />
RESTful service</P><br />
<P>Chapter 7: <I>Deploying RESTful Services with CXF</I> will explain how to deploy<br />
REST services in a container like Tomcat using Spring configuration, and how to<br />
test out the various operations exposed by the RESTFul application using CXF RESTful<br />
client APiusing a web service development tool. We will look at how to enable<br />
exception handling, JSON message support, and logging support for RESTful<br />
applications using CXF framework.</P><br />
<P>By the end of this chapter the reader would be able utilize various CXF features for<br />
developing RESTful services and how to leverage Spring configuration for deploying<br />
RESTful service in the tomcat container.</P><br />
<P>Chapter 8: <I>Working with CXF Tools</I> will explain some of the commonly used CXF<br />
tools that assist us in web services development. We will look at how to invoke a real<br />
world .NET service over the internet using a Java client and JavaScript, create web<br />
service implementation from WSDL files, generate WSDL files from web service<br />
implementation, and validate the WSDL file for compliance.</P><br />
<P>By the end of this chapter the reader will be able to use different CXF tools to<br />
develop a service.</P><br />
<P><I>Appendix A</I> deals with how to set up the CXF environment, provides details on how the<br />
source code for each chapter is organized, and shows how to run the source code<br />
examples using the ANT tool and Maven Tool.</P><br />
<P><I>Appendix B</I> provides an explanation of the basics of the Spring framework and IoC<br />
concepts, along with an end-to-end example which utilizes Spring IoC concepts.</P><br />
<P>By the end of this Appendix chapter the reader will have a good understanding of Spring<br />
capabilities used in the context of CXF web services development in this book.</P><br />
<H1><CENTER>Developing a Web Service with CXF</CENTER></H1><br />
<P>The first chapter provided an introduction to web services and CXF framework. We<br />
looked at the features supported by the CXF framework and how to set up the CXF<br />
environment. This chapter will focus on programming web service with CXF. CXF<br />
provides a robust programming model that offers simple and convenient APIs for<br />
web service development. The chapter will focus on illustrating a simple web service<br />
development using CXF and Spring-based configurations. The chapter will also talk<br />
about the architecture of CXF.</P><br />
<P>Before we examine CXF-based web service development, we will review the example<br />
application that will be illustrated throughout the book. The example application<br />
will be called <B>Order Processing Application</B>. The book will demonstrate the same<br />
application to communicate different concepts and features of CXF so that the reader<br />
can have a better understanding of CXF as a whole. This chapter will focus on the<br />
following topics:</P><br />
<UL><br />
<LI>Overview of a sample Order Processing Application</LI><br />
<LI>CXF-based web service development with Spring</LI><br />
<LI>Insight into CXF architecture</LI><br />
</UL><br />
<H1>The Order Processing Application</H1><br />
<P>The objective of the Order Processing Application is to process a customer order.<br />
The order process functionality will generate the customer order, thereby making<br />
the order valid and approved. A typical scenario will be a customer making an<br />
order request to buy a particular item. The purchase department will receive the<br />
order request from the customer and prepare a formal purchase order. The purchase<br />
order will hold the details of the customer, the name of the item to be purchased,<br />
the quantity, and the price. Once the order is prepared, it will be sent to the<br />
Order Processing department for the necessary approval. If the order is valid and<br />
approved, then the department will generate the unique order ID and send it back to<br />
the Purchase department. The Purchase department will communicate the order ID<br />
back to the customer.</P><br />
<P><CENTER><IMG SRC="images/2010/07/Apache-cfx/1.jpg"/></CENTER></P><br />
<P>For simplicity, we will look at the following use cases:</P><br />
<UL><br />
<LI>Prepare an order</LI><br />
<LI>Process the order</LI><br />
</UL><br />
<P>The client application will prepare an order and send it to the server application<br />
through a business method call. The server application will contain a web service<br />
that will process the order and generate a unique order ID. The generation of the<br />
unique order ID will signify order approval.</P><br />
<P><PRE><CODE><br />
	In real world applications a unique order ID is always accompanied by<br />
	the date the order was approved. However, in this example we chose to<br />
	keep it simple by only generating order ID.<br />
</CODE></PRE></P><br />
<H1>Developing a service</H1><br />
<P>Let&#8217;s look specifically at how to create an Order Processing Web Service and then<br />
register it as a Spring bean using a JAX-WS frontend.</P><br />
<P><PRE><CODE><br />
	In Chapter 3 you will learn about the JAX-WS frontend. The chapter<br />
	will also cover a brief discussion on JAX-WS. The Sun-based JAX-WS<br />
	specification can be found at the following URL:</p>
<p>http://jcp.org/aboutJava/communityprocess/final/</p><div class="wpInsert wpInsertInPostAd wpInsertMiddle" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Middle-Med-Rect */
google_ad_slot = "7805667846";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
<p>	jsr224/index.html<br />
</CODE></PRE></P><br />
<P>JAX-WS frontend offers two ways of developing a web service—Code-first and<br />
Contract-first. We will use the <I>Code-first</I> approach, that is, we will first create a Java<br />
class and convert this into a web service component. The first set of tasks will be to<br />
create server-side components.</P><br />
<P><PRE><CODE><br />
	In web service terminology, Code-first is termed as the Bottoms Up<br />
	approach, and Contract-first is referred to as the Top Down approach.<br />
</CODE></PRE></P><br />
<P>To achieve this, we typically perform the following steps:</P><br />
<UL><br />
<LI>Create a <B>Service Endpoint Interface (SEI)</B> and define a business method<br />
to be used with the web service.</LI><br />
<LI>Create the implementation class and annotate it as a web service.</LI><br />
<LI> Create beans.xml and define the service class as a Spring bean using a<br />
JAX-WS frontend.</LI><br />
</UL></p>
<div class="wpInsert wpInsertInPostAd wpInsertBelow" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* JB-Footer-LU 468x15 */
google_ad_slot = "8789107210";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>]]></content:encoded>
			<wfw:commentRss>http://www.javabeat.net/2010/07/developing-a-web-service-with-cxf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AXIS 2.0 Architecture</title>
		<link>http://www.javabeat.net/2008/12/axis-2-0/</link>
		<comments>http://www.javabeat.net/2008/12/axis-2-0/#comments</comments>
		<pubDate>Tue, 23 Dec 2008 16:00:28 +0000</pubDate>
		<dc:creator>krishnas</dc:creator>
				<category><![CDATA[Webservices]]></category>
		<category><![CDATA[AXIS 2.0]]></category>

		<guid isPermaLink="false">http://www.javabeat.net/?p=2240</guid>
		<description><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><p>Looking into Axis 2.0What This Book Covers This book is organized in a such a way that it will lead you to gain a very good understanding of Web Services and AXIS 2.0. At the end of the book, you will have become familiar with most of the commonly used AXIS 2.0 features and concepts. You will be [...]</p>]]></description>
				<content:encoded><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><div class="wpInsert wpInsertInPostAd wpInsertLeft" style="float: left; margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Rect */
google_ad_slot = "9976259118";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><p><center><strong>Looking into Axis 2.0</strong></center><strong>What This Book Covers</strong></p>
<p>This book is organized in a such a way that it will lead you to gain a very good understanding of Web Services and <b><i>AXIS 2.0</i></b>. At the end of the book, you will have become familiar with most of the commonly used <b><i>AXIS 2.0</i></b> features and concepts. You will be able to write a Web Service, invoke a remote Service, and extend the core functionality of <b><i>AXIS 2.0</i></b>.</p>
<ul>
<li>Chapter 1 defines Web Services, their architecture, and components. It also discusses the Apache Web Services stack and the motivation for <b><i>AXIS 2.0</i></b>. Finally, it tells you how to go about downloading and deploying <b><i>AXIS 2.0</i></b>.</li>
<li>Chapter 2 gives an overview of the <b><i>AXIS 2.0</i></b> architecture, its dominant features and extensible nature. Furthermore, it opens the way to learning key terminologies used in <b><i>AXIS 2.0</i></b> and getting familiar with them.</li>
<li>Chapter 3 introduces AXIOM, the <b><i>AXIS 2.0</i></b> object model and discusses the key features of AXIOM with code samples.</li>
<li>Chapter 4 discusses the smallest execution unit in <b><i>AXIS 2.0</i></b>—a handler, and then discusses phase and phase rules. Finally, it describes the execution chain and how to change it using phase rules.</li>
<li>Chapter 5 describes how deployment works and available deployment mechanisms in <b><i>AXIS 2.0</i></b>.</li>
<li>Chapter 6 discusses the dynamic and static data hierarchies in <b><i>AXIS 2.0</i></b>; how they are stored, how they get created and related, and so on.</li>
<li>Chapter 7 discusses everything you need to know about how to write and deploy a Web Service in <b><i>AXIS 2.0</i></b>. This includes both POJO and archive-based service development. Chapter 8 discusses everything about how to write and deploy a service extension or a module in <b><i>AXIS 2.0</i></b>.</li>
<li>Chapter 9 discusses the <b><i>AXIS 2.0</i></b> client API, synchronous and asynchronous Web Service invocations, and different configuration options available for the client side.</li>
<li>Chapter 10—If you are looking to implement session-aware services then this chapter will help you out as it describes the types of available sessions in <b><i>AXIS 2.0</i></b> and their proper usage.</li>
<li>Chapter 11 describes how <b><i>AXIS 2.0</i></b> handles POJOs, <b><i>AXIS 2.0</i></b> data-binding, and code generation.</li>
<li><em id="__mceDel">Chapter 12 discusses other features of <b><i>AXIS 2.0</i></b> such as REST support and MTOM as well as the advanced configuration mechanism of <b><i>AXIS 2.0</i></b>. Finally, it discusses deploying <b><i>AXIS 2.0 </i></b>in various application severs.</em></li>
</ul>
<p>Flexibility and extensibility are two main design criteria that software designers would like to have in their applications. When it comes to <b><i>AXIS 2.0</i></b>, its architecture is extremely flexible and extensible. <b><i>AXIS 2.0</i></b> has a modular architecture. In this chapter, we will learn more about <b><i>AXIS 2.0</i></b> architecture, its core components, and its main features.</p>
<h2><b><i>AXIS 2.0</i></b> Architecture</h2>
<p><b><i>AXIS 2.0</i></b> is built upon a modular architecture that consists of core modules and non-core modules. The core engine is said to be a pure SOAP processing engine (there is not any JAX-PRC concept burnt into the core). Every message coming into the system has to be transformed into a SOAP message before it is handed over to the core engine. An incoming message can either be a SOAP message or a non-SOAP message (REST JSON or JMX). But at the transport level, it will be converted into a SOAP message.</p>
<p>When <b><i>AXIS 2.0</i></b> was designed, the following key rules were incorporated into the architecture. These rules were mainly applied to achieve a highly flexible and extensible SOAP processing engine:</p>
<ul>
<li>Separation of logic and state to provide a stateless processing mechanism. (This is because Web Services are stateless.)</li>
<li>A single information model in order to enable the system to suspend and resume.</li>
<li>Ability to extend support to newer Web Service specifications with minimal changes made to the core architecture.</li>
</ul>
<p>The figure below shows all the key components in <b><i>AXIS 2.0</i></b> architecture (including core components as well as non-core components).</p>
<p><a href="http://www.javabeat.net/wp-content/uploads/2008/12/axis-1.bmp"><img class="aligncenter size-full wp-image-6788" alt="axis-1" src="http://www.javabeat.net/wp-content/uploads/2008/12/axis-1.bmp" /></a></p>
<h2>Core Modules</h2>
<ul>
<li>XML Processing Model: Managing or processing the SOAP message is the most difficult part of the execution of a message. The efficiency of message processing is the single most important factor that decides the performance of the entire system. Axis1 uses DOM as its message representation mechanism. However, <b><i>AXIS 2.0</i></b> introduced a fresh XML InfoSet-based representation for SOAP messages. It is known as AXIOM (AXIs Object Model). AXIOM encapsulates the complexities of efficient XML processing within the implementation.</li>
<li>SOAP Processing Model: This model involves the processing of an incoming SOAP message. The model defines the different stages (phases) that the execution will walk through. The user can then extend the processing model in specific places.</li>
<li>Information Model: This keeps both static and dynamic states and has the logic to process them. The information model consists of two hierarchies to keep static and run-time information separate. Service life cycle and service session management are two objectives in the information model.</li>
<li>Deployment Model: The deployment model allows the user to easily deploy the services, configure the transports, and extend the SOAP Processing Model. It also introduces newer deployment mechanisms in order to handle hot deployment, hot updates, and J2EE-style deployment.</li>
<li>Client API: This provides a convenient API for users to interact with Web Services using <b><i>AXIS 2.0</i></b>. The API consists of two sub-APIs, for average and advanced users. <b><i>AXIS 2.0</i></b> default implementation supports all the eight MEPs (Message Exchange Patterns) defined in WSDL 2.0. The API also allows easy extension to support custom MEPs.</li>
<li>Transports: <b><i>AXIS 2.0</i></b> defines a transport framework that allows the user to use and expose the same service in multiple transports. The transports fit into specific places in the SOAP processing model. The implementation, by default, provides a few common transports (HTTP, SMTP, JMX, TCP and so on). However, the user can write or plug-in custom transports, if needed.</li>
</ul>
<h2>XML Processing Model</h2>
<p>As mentioned in Chapter 1, <b><i>AXIS 2.0</i></b> is built on a completely new architecture as compared to Axis 1.x. One of the key reasons for introducing <b><i>AXIS 2.0</i></b> was to have a better, and an efficient XML processing model. Axis 1.x used DOM as its XML representation mechanism, which required the complete object hierarchy (corresponding to incoming message) to be kept in memory. This will not be a problem for a message of small size. But when it comes to a message of large size, it becomes an issue. To overcome this problem, <b><i>AXIS 2.0</i></b> has introduced a new XML representation.</p>
<p>AXIOM (AXIs Object Model) forms the basis of the XML representation for every SOAP-based message in <b><i>AXIS 2.0</i></b>. The advantage of AXIOM over other XML InfoSet representations is that it is based on the PULL parser technique, whereas most others are based on the PUSH parser technique. The main advantage of PULL over PUSH is that in the PULL technique, the invoker has full control over the parser and it can request the next event and act upon that, whereas in case of PUSH, the parser has limited control and delegates most of the functionality to handlers that respond to the events that are fired during its processing of the document.</p>
<p>Since AXIOM is based on the PULL parser technique, it has &#8216;on-demand-building&#8217; capability whereby it will build an object model only if it is asked to do so. If required, one can directly access the underlying PULL parser from AXIOM, and use that rather than build an OM (Object Model).</p>
<h2>SOAP Processing Model</h2>
<p>Sending and receiving SOAP messages can be considered two of the key jobs of the SOAP-processing engine. The architecture in <b><i>AXIS 2.0</i></b> provides two Pipes (&#8216;Flows&#8217;), in order to perform two basic actions. The AxisEngine or driver of <b><i>AXIS 2.0</i></b> defines two methods, send() and receive() to implement these two Pipes. The two pipes are named InFlow and OutFlow. The complex Message Exchange Patterns (MEPs) are constructed by combining these two types of pipes. It should be noted that in addition to these two pipes there are two other pipes as well, and those two help in handling incoming Fault messages and sending a Fault message.</p>
<p>Extensibility of the SOAP processing model is provided through handlers. When a SOAP message is being processed, the handlers that are registered will be executed. The handlers can be registered in global, service, or in operation scopes, and the final handler chain is calculated by combining the handlers from all the scopes.</p>
<p>The handlers act as interceptors, and they process parts of the SOAP message and provide the quality of service features (a good example of quality of service is security or reliability). Usually handlers work on the SOAP headers; but they may access or change the SOAP body as well.</p>
<p>The concept of a flow is very simple and it constitutes a series of phases wherein a phase refers to a collection of handlers. Depending on the MEP for a given method invocation, the number of flows associated with it may vary. In the case of an in-only MEP, the corresponding method invocation has only one pipe, that is, the message will only go through the in pipe (inflow). On the other hand, in the case of in-out MEP, the message will go through two pipes, that is the in pipe (inflow) and the out pipe (outflow). When a SOAP message is being sent, an OutFlow begins. The OutFlow invokes the handlers and ends with a Transport Sender that sends the SOAP message to the target endpoint. The SOAP message is received by a Transport Receiver at the target endpoint, which reads the SOAP message and starts the InFlow. The InFlow consists of handlers and ends with the Message Receiver, which handles the actual business logic invocation.</p>
<p>A phase is a logical collection of one or more handlers, and sometimes a phase itself acts as a handler. <b><i>AXIS 2.0</i></b> introduced the phase concept as an easy way of extending core functionalities. In Axis 1.x, we need to change the global configuration files if we want to add a handler into a handler chain. But <b><i>AXIS 2.0</i></b> makes it easier by using the concept of phases and phase rules. Phase rules specify how a given set of handlers, inside a particular phase, are ordered. The figure below illustrates a flow and its phases.</p>
<p><a href="http://www.javabeat.net/wp-content/uploads/2008/12/axis-2.gif"><img class="aligncenter size-full wp-image-6789" alt="axis-2" src="http://www.javabeat.net/wp-content/uploads/2008/12/axis-2.gif" width="378" height="80" /></a></p>
<p>If the message has gone through the execution chain without having any problem, then the engine will hand over the message to the message receiver in order to do the business logic invocation, After this, it is up to the message receiver to invoke the service and send the response, if necessary. The figure below shows how the Message Receiver fits into the execution chain.</p>
<p><a href="http://www.javabeat.net/wp-content/uploads/2008/12/axis-3.gif"><img class="aligncenter size-full wp-image-6790" alt="axis-3" src="http://www.javabeat.net/wp-content/uploads/2008/12/axis-3.gif" width="434" height="65" /></a></p>
<p>The two pipes do not differentiate between the server and the client. The SOAP processing model handles the complexity and provides two abstract pipes to the user. The different areas or the stages of the pipes are named &#8216;phases&#8217; in <b><i>AXIS 2.0</i></b>.</p>
<p>A handler always runs inside a phase, and the phase provides a mechanism to specify the ordering of handlers. Both pipes have built-in phases, and both define the areas for &#8216;User Phases&#8217;, which can be defined by the user, as well.</p>
<h2>Information Model</h2>
<p>As shown in the figure below, the information model consists of two hierarchies: &#8220;Description hierarchy&#8221; and &#8220;Context hierarchy&#8221;. The Description hierarchy represents the static data that may come from different deployment descriptors. If hot deployment is turned off, then the description hierarchy is not likely to change. If hot deployment is turned on, then we can deploy the service while the system is up and running. In this case, the description hierarchy is updated with the corresponding data of the service. The context hierarchy keeps run-time data. Unlike the description hierarchy, the context hierarchy keeps on changing when the server starts receiving messages.</p>
<p>These two hierarchies create a model that provides the ability to search for key value pairs. When the values are to be searched for at a given level, they are searched while moving up the hierarchy until a match is found. In the resulting model, the lower levels override the values present in the upper levels. For example, when a value has been searched for in the Message Context and is not found, then it would be searched in the Operation Context, and so on. The search is first done up the hierarchy, and if the starting point is a Context then it would search for in the Description hierarchy as well.</p>
<p>This allows the user to declare and override values, with the result being a very flexible configuration model. The flexibility could be the Achilles&#8217; heel of the system, as the search is expensive, especially for something that does not exist.</p><div class="wpInsert wpInsertInPostAd wpInsertMiddle" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Middle-Med-Rect */
google_ad_slot = "7805667846";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
<p><a href="http://www.javabeat.net/wp-content/uploads/2008/12/axis-4.gif"><img class="aligncenter size-full wp-image-6791" alt="axis-4" src="http://www.javabeat.net/wp-content/uploads/2008/12/axis-4.gif" width="243" height="311" /></a></p>
<h2>Deployment Model</h2>
<p>The previous versions of Axis failed to address the usability factor involved in the deployment of a Web Service. This was due to the fact that Axis 1.x was released mainly to prove the Web Service concepts. Therefore in Axis 1.x, the user has to manually invoke the admin client and update the server classpath. Then, you need to restart the server in order to apply the changes. This burdensome deployment model was a definite barrier for beginners. <b><i>AXIS 2.0</i></b> is engineered to overcome this drawback, and provide a flexible, user-friendly, easily configurable deployment model.</p>
<p><b><i>AXIS 2.0</i></b> deployment introduced a J2EE-like deployment mechanism, wherein the developer can bundle all the class files, library files, resources files, and configuration files together as an archive file, and drop it in a specified location in the file system.</p>
<p>The concept of hot deployment and hot update is not a new technical paradigm, particularly for the Web Service platform. But in the case of Apache Axis, it is a new feature. Therefore, when <b><i>AXIS 2.0</i></b> was developed, &#8220;hot&#8221; deployment features were added to the feature list.</p>
<ul>
<li>Hot deployment: This refers to the capability to deploy services while the system is up and running. In a real time system or in a business environment, the availability of the system is very important. If the processing of the system is slow, even for a moment, then the loss might be substantial and it may affect the viability of the business. In the meanwhile, it is required to add new service to the system. If this can be done without needing to shut down the servers, it will be a great achievement. <b><i>AXIS 2.0</i></b> addresses this issue and provides a Web Service hot deployment ability, wherein we need not shut down the system to deploy a new Web Service. All that needs to be done is to drop the required Web Service archive into the services directory in the repository. The deployment model will automatically deploy the service and make it available.</li>
<li>Hot update: This refers to the ability to make changes to an existing Web Service without even shutting down the system. This is an essential feature, which is best suited to use in a testing environment. It is not advisable to use hot updates in a real-time system, because a hot update could lead a system into an unknown state. Additionally, there is the possibility of loosening the existing service data of that service. To prevent this, <b><i>AXIS 2.0</i></b> comes with the hot update parameter set to FALSE by default.</li>
</ul>
<h2>Client API</h2>
<p>Nowadays, asynchronous or non-blocking Web Service invocation is a key requirement in Web Services. There are currently two approaches to invoking a Web Service in a non-blocking manner. The first is the client programming model, where a client invokes the service in a non-blocking manner. The second way is the transport level non-blocking invocation where invocation occurs in two transports (it could either be two single-channel transports like SMTP, or two double-channel transports like HTTP). <b><i>AXIS 2.0</i></b> client API supports both the non-blocking invocation scenarios.</p>
<p><b><i>AXIS 2.0</i></b> introduces a very convenient client API for invoking services that consists of two classes called &#8220;ServiceClient&#8221; and &#8220;OperationClient&#8221;. The ServiceClient API is intended for regular usage when you just require to send and receive XML. On the other hand, the operation client is meant for advanced usage, when there is a need to work with SOAP headers and some other advanced tasks. With ServiceClient, we can only access the SOAP body or the payload. Although we can add SOAP headers, we do not have any way to retrieve the SOAP header by using the ServiceClient. We need to use an OperationClient for such a function.</p>
<p>ServiceClient has the following API for invoking a service:</p>
<ul>
<li>sendRobust: The whole idea of this is to just send an XML request to the Web Service and not care about its response. However, if something goes wrong, we require to know that too, so this API invokes a service, where it does not have a return value but would throw an exception.</li>
<li>FireAndForget: This API is for just sending an XML request and not caring about either the response, or any exception. Hence, this is useful in invoking an in-only MEP.</li>
<li>SendReceive: This invokes a service that has a return value. This is one of the most commonly used APIs. Hence, this is used for invoking an in-out MEP.</li>
<li>SendReceiveNonBlocking: This invokes a service in a non-blocking manner. This method can be used when the service has a return value. In order to use this method, we have to pass a callback object, which is called once the invocation is complete.</li>
</ul>
<p>As mentioned earlier, the OperationClient class is for advanced users, and working with OperationClient requires us to know <b><i>AXIS 2.0</i></b> in depth. In ServiceClient, we do not have to know anything about SOAP envelope, message context, and so on. But when it comes to OperationClient, the users have to create these by themselves, before invoking a service. Creating and invoking a service using OperationClient involves the following steps:</p>
<ul>
<li>Create a ServiceClient.</li>
<li>Then create OperationClient with the use of the ServiceClient that we have created.</li>
<li>Create SOAP envelop.</li>
<li>Create Message context.</li>
<li>Add the SOAP envelope to message context.</li>
<li>Add the messagecontext to OperationClient.</li>
<li>Then invoke the OperationClient.</li>
<li>If there is a response, then get the response message context from the OperationClient.</li>
</ul>
<h2>Transports</h2>
<p>In <b><i>AXIS 2.0</i></b>, each and every transport consists of two parts, namely &#8220;Transport Senders&#8221; and &#8220;Transport Receivers&#8221;. We can define transports along with senders and receivers in <b><i>AXIS 2.0</i></b> global configuration. The Transport Receiver is the one via which, the AxisEngine receives the message whereas the transport sender is the one that sends out the message. One of the important aspects of <b><i>AXIS 2.0</i></b> is that its core is completely independent of the transport sender and receiver.</p>
<p><b><i>AXIS 2.0</i></b> is built to support the following transport protocols:</p>
<ul>
<li>HTTP/HTTPS: In HTTP transport, the transport listener is a servlet or org. apache.axis2.transport.http.SimpleHTTPServer provided by <b><i>AXIS 2.0</i></b>. The transport sender uses a common HTTP client for connection and sends the SOAP message.</li>
<li>TCP: This is the simplest transport and it needs WS-Addressing support in order to be functional.</li>
<li>SMTP: This requires a single email account. The transport receiver is a thread that checks for emails at fixed time intervals.</li>
<li>JMS: This provides a way to invoke a Web Service using the JMS way.</li>
<li>XMPP: This provides a standard way to communicate with Jabber server, and to invoke Web Services using XMPP protocol.</li>
</ul>
<h2>Other Modules</h2>
<ul>
<li>Code Generation: <b><i>AXIS 2.0</i></b> provides a code generation tool that generates server-side (skeleton) and client-side (stub or proxy) code along with descriptors and a test case. The generated code simplifies the service deployment and the service invocation. This increases the usability of <b><i>AXIS 2.0</i></b>.</li>
<li>Pluggable Data Binding: The basic client API of <b><i>AXIS 2.0</i></b> lets the user process SOAP at the XML infoset level, whereas data binding extends it to make it more convenient for the users by encapsulating the infoset layer and providing a programming language-specific interface.</li>
</ul>
<h2>Code Generation</h2>
<p>Although the basic objective of the code generation tools has not changed, the code generation module of <b><i>AXIS 2.0</i></b> has adopted a different approach. Primarily, the change is in the use of templates, namely XSL templates, which gives flexibility to the code generator so as to generate code in multiple languages.</p>
<h2>Data Binding</h2>
<p>Databinding for <b><i>AXIS 2.0</i></b> is implemented in an interesting manner. Databinding has deliberately not been included in the core, and hence the code generation allows different data binding frameworks to be plugged in. This is done through an extension mechanism where the codegen engine calls the extensions first, and then executes the core emitter. The extensions plot a map of QNames versus class names that is passed to the code generator wherein the emitter operates.</p>
<p><b><i>AXIS 2.0</i></b> supports the following data binding frameworks including its own data binding framework called ADB:</p>
<ul>
<li>ADB: ADB (<b><i>AXIS 2.0</i></b> Data Binding) is a simple and lightweight framework that works off StAX and is fairly performant.</li>
<li>XMLBeans: XMLBeans is preferred if we want to use full schema support as XMLBeans claims that it supports complete schema specification.</li>
<li>JaxMe: JaxMe support has been added to XMLBeans, and it serves as another option for the user.</li>
<li>JibX: This is the most recent addition to the family of data binding extensions.</li>
</ul>
<h2>Extensible Nature of <b><i>AXIS 2.0</i></b></h2>
<p>In <b><i>AXIS 2.0</i></b>, there are many ways to extend the functionalities. In this book, we will be discussing a few of them, which are listed below:</p>
<ul>
<li>Service extension of the module</li>
<li>Custom deployers</li>
<li>Message Receivers</li>
</ul>
<h2>Service Extension of the Module</h2>
<p>Both Axis1 and <b><i>AXIS 2.0</i></b> have the concept of handlers but when compared to Axis 1.x, there are few changes in the way <b><i>AXIS 2.0</i></b> specifies and deploys handlers. In Axis 1.x, if you want to add a handler, then you need to change the global configuration file and then restart the system. In the meantime, it does not have a way to add or change handlers dynamically.</p>
<p>To overcome the above problem as well as to add new features, <b><i>AXIS 2.0</i></b> introduced the concept of Web Service extensions or a modules, wherein the main purpose of a module is to extend the core functionality. It is similar to adding handler chains in Axis1.x. The advantage of <b><i>AXIS 2.0</i></b> modules over Axis 1.x handler chains is that we can add new modules without changing any global configuration files.</p>
<p>A module is a self-contained package that includes handlers, third-party libraries, module-related resources, and a module configuration file.</p>
<p>A module can be deployed as an archive file. <b><i>AXIS 2.0</i></b> came up with a new file extension for modules, called &#8220;.mar&#8221;. The most important file in a module archive file is the module configuration file or module.xml. A module will not be functional unless it has a module.xml file. A module configuration file mainly specifies handlers and their phase rules. So once we engage a module, depending on the phase rule, the handlers will be placed in different flows (inflow, outflow, and so on).</p>
<p>The idea of modules is very simple. To implement support for WS-Addressing or WS-Security in our services, we need to download the corresponding modules and drop them into the modules directory of the <b><i>AXIS 2.0</i></b> repository. We can engage the module at deployment time by adding &lt;module ref=&#8221;module name&#8221;/&gt; to axis2. xml (global configuration file). In addition to that, if we want to engage a module at run time, we can do that in many ways such as by using <b><i>AXIS 2.0</i></b> web admin, handlers, and so on.</p>
<h2>Custom Deployers</h2>
<p>We can deploy a service in many ways. We could deploy a service as an archive file (<b><i>AXIS 2.0</i></b> default), by creating a service using a database, or by creating a Web Service using a text file. The idea of custom deployers is to open avenues to support any kind of deployment mechanisms. <b><i>AXIS 2.0</i></b> has in-built support for:</p>
<ul>
<li>Archive-based deployment (.aar and .mar concept)</li>
<li>POJO deployment (.class or .jar)</li>
</ul>
<p>But if someone wants to deploy a service, or a module, then he or she can achieve that goal with the use of custom deployers. We will discuss more about custom deployers in Chapter 5.</p>
<h2>Message Receivers</h2>
<ul>
<li>As we have discussed, the <b><i>AXIS 2.0</i></b> execution chain is a collection of phases wherein each phase is a logical group of handlers. The Message Receiver, in itself, is a handler. However, it is different from other handlers because <b><i>AXIS 2.0</i></b> treats the Message Receiever in a different manner. If the message has gone through the inflow with no issues, or in other words, no exceptions have occurred in the middle of the chain, then the engine hands over the message to the message receiver so as to invoke the associated business logic.</li>
<li>Message receivers interact directly with both the actual service implementation class and the AxisEngine. However, there can be some instances wherein there are no service implementation classes and all the logic is handed inside the Message Receiver. The message receiver is the last component in the inflow process. <b><i>AXIS 2.0</i></b> has got nothing to do with it once the message is handled over to the message receiver.</li>
</ul>
<h2>Summary</h2>
<p><b><i>AXIS 2.0</i></b> is enterprise-ready. Its Web Service engine provides a better SOAP processing model, with considerable increase in performance for both speed and memory usage with respect to Axis 1.x and other existing Web Service engines. In addition, it provides the user with a convenient API for service deployment, extending the core functionality, and thus acting as a new client programming model. In this chapter, we have learned about the internals and architecture of <b><i>AXIS 2.0</i></b>. Thus, we have learned that <b><i>AXIS 2.0</i></b> architecture helps in attaining a more flexible and extensible <b><i>AXIS 2.0</i></b>.</p>
<div class="wpInsert wpInsertInPostAd wpInsertBelow" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* JB-Footer-LU 468x15 */
google_ad_slot = "8789107210";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>]]></content:encoded>
			<wfw:commentRss>http://www.javabeat.net/2008/12/axis-2-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JAX-WS Web Services in NetBeans 6.1</title>
		<link>http://www.javabeat.net/2008/08/jax-ws-web-services-in-netbeans-6-1/</link>
		<comments>http://www.javabeat.net/2008/08/jax-ws-web-services-in-netbeans-6-1/#comments</comments>
		<pubDate>Tue, 05 Aug 2008 13:07:08 +0000</pubDate>
		<dc:creator>krishnas</dc:creator>
				<category><![CDATA[NetBeans]]></category>
		<category><![CDATA[Webservices]]></category>
		<category><![CDATA[JAX-WS WebServices]]></category>

		<guid isPermaLink="false">http://www.javabeat.net/?p=200</guid>
		<description><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><p>Java API for XML Web Services(JAX-WS) is an important part of latest JEE specification (Java EE 5 platform). In this article we will see how to develop JAX-WS based web services using NetBeans 6.1 IDE. This article will not provide any of the theoretical information about JAX-WS. Software used NetBeans 6.1 Java 5.0/6.0 GlassFish V2 [...]</p>]]></description>
				<content:encoded><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><div class="wpInsert wpInsertInPostAd wpInsertLeft" style="float: left; margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Rect */
google_ad_slot = "9976259118";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><p><strong style="font-size: 13px;"><em>Java API for XML Web Services(JAX-WS)</em></strong><span style="font-size: 13px;"> is an important part of latest JEE specification (Java EE 5 platform). In this article we will see how to develop </span><strong style="font-size: 13px;"><em>JAX-WS</em></strong><span style="font-size: 13px;"> based </span><em style="font-size: 13px;">web services</em><span style="font-size: 13px;"> using </span><strong style="font-size: 13px;"><em>NetBeans 6.1</em></strong><span style="font-size: 13px;"> IDE. This article will not provide any of the theoretical information about </span><strong style="font-size: 13px;"><em>JAX-WS</em></strong><span style="font-size: 13px;">.</span></p>
<h2>Software used</h2>
<ul>
<li><strong><em>NetBeans 6.1 </em></strong></li>
<li><strong><em>Java 5.0/6.0</em></strong></li>
<li><strong><em>GlassFish V2</em></strong></li>
</ul>
<h2>Creating a Web project in NetBeans 6.1</h2>
<p>To start with first of all we will have to create a web application from the web category. Let us name the project as &#8220;MyJaxWSApplication&#8221;. To create a create a web application we will do the following.</p>
<p>1. Choose File &gt; New Project. Select Web Application from the Web category. Name the project as &#8220;MyJaxWSApplication&#8221; and click on Next.</p>
<p><a href="http://www.javabeat.net/wp-content/uploads/2008/08/1.png"><img class="aligncenter size-medium wp-image-917" title="1" alt="" src="http://www.javabeat.net/wp-content/uploads/2008/08/1-300x185.png" width="300" height="185" /></a></p>
<p>2. In Server and Settings select the server that you want to use. Here we are going to use GlassFish.</p>
<p><a href="http://www.javabeat.net/wp-content/uploads/2008/08/2.png"><img class="aligncenter size-medium wp-image-920" title="2" alt="" src="http://www.javabeat.net/wp-content/uploads/2008/08/2-300x185.png" width="300" height="185" /></a></p>
<p>3. Click Next and Finish.</p>
<p>Now its time to create <strong><em>web service</em></strong> form Java class</p>
<h2>Creating Web Service project in NetBeans 6.1</h2>
<ul>
<ul>
<li>Select the project you created and right click on the project node.</li>
<li>Choose New &gt; <strong><em>Web Service</em></strong>.</li>
</ul>
</ul>
<p><a href="http://www.javabeat.net/wp-content/uploads/2008/08/3.png"><img class="aligncenter size-medium wp-image-922" title="3" alt="" src="http://www.javabeat.net/wp-content/uploads/2008/08/3-300x158.png" width="300" height="158" /></a></p>
<ul>
<ul>
<li>A New <strong><em>Web service</em></strong> dialog window will open. Give the web service name as &#8220;Adder&#8221;, give the package name as &#8220;ws&#8221;. Make sure Create web service from scrach option is selected. Click on finish.</li>
</ul>
</ul>
<p><a href="http://www.javabeat.net/wp-content/uploads/2008/08/4.png"><img class="aligncenter size-medium wp-image-925" title="4" alt="" src="http://www.javabeat.net/wp-content/uploads/2008/08/4-300x223.png" width="300" height="223" /></a></p><div class="wpInsert wpInsertInPostAd wpInsertMiddle" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Middle-Med-Rect */
google_ad_slot = "7805667846";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
<ul>
<ul>
<li><strong><em>Web Services</em></strong> node will get created in projects window. Web Services node will contain a Adder node indicating the new <strong><em>web service</em></strong> we created just now. In the editor window area visual designer will open up as shown below.</li>
</ul>
</ul>
<p><a href="http://www.javabeat.net/wp-content/uploads/2008/08/5.png"><img class="aligncenter size-medium wp-image-927" title="5" alt="" src="http://www.javabeat.net/wp-content/uploads/2008/08/5-300x154.png" width="300" height="154" /></a></p>
<ul>
<ul>
<li>Click Add Operation in the visual designer. A dialog box appears where you can define the new operation. In the dialog box enter the name of the service as &#8220;Add2Numbers&#8221; set the return type to &#8220;int&#8221;, then add two parameters. name the parameters as &#8220;number1&#8243; and &#8220;number2&#8243; select the type of both the parameters as &#8220;int&#8221;. Then click on OK</li>
</ul>
</ul>
<p><a href="http://www.javabeat.net/wp-content/uploads/2008/08/6.png"><img class="aligncenter size-medium wp-image-929" title="6" alt="" src="http://www.javabeat.net/wp-content/uploads/2008/08/6-300x233.png" width="300" height="233" /></a></p>
<ul>
<ul>
<li>The designer now displays the following:</li>
</ul>
</ul>
<p><a href="http://www.javabeat.net/wp-content/uploads/2008/08/7.png"><img class="aligncenter size-medium wp-image-931" title="7" alt="" src="http://www.javabeat.net/wp-content/uploads/2008/08/7-300x202.png" width="300" height="202" /></a></p>
<ul>
<ul>
<li>Now see the source genarated by the IDE by clicking on source tab in the visual designer. The IDE will generate the following source for you.</li>
</ul>
</ul>
<pre class="brush: java; title: ; notranslate">
package ws;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;

/**
*
* @author Sri hari
*/
@WebService()
public class Adder {

/**
 * Web service operation
 */
@WebMethod(operationName = &quot;Add2Numbers&quot;)
public int Add2Numbers(@WebParam(name = &quot;number1&quot;)
int number1, @WebParam(name = &quot;number2&quot;)
int number2) {
	//TODO write your implementation code here:
	return 0;
}

}</pre>
<ul>
<ul>
<li>Now change the Add2Numbers method like the following, So that our operation will simply add two numbers and return the result.</li>
</ul>
</ul>
<pre class="brush: java; title: ; notranslate">
/**
 * Web service operation
 */
@WebMethod(operationName = &quot;Add2Numbers&quot;)
public int Add2Numbers(@WebParam(name = &quot;number1&quot;)
int number1, @WebParam(name = &quot;number2&quot;)
int number2) {
	return number1 + number2;
}</pre>
<ul>
<li>Now we successfully developed a web service wich will add two numbers.</li>
</ul>
<h2>Web Service Deployment in NetBeans 6.1</h2>
<p>Now we will deploy the web service like below:</p>
<ul>
<li>Right click the project node and select Undeploy and Deploy.</li>
<li>Once you do that IDE will start the server (GlassFish) and deploys the application to the server.</li>
</ul>
<h2>Web Service Testing in NetBeans 6.1</h2>
<p>Now its time to test the web service.</p>
<p>In the IDE&#8217;s Projects tab, expand the <strong><em>Web Services</em></strong> node of the project. Right-click the services node, and choose Test <strong><em>Web Service</em></strong>. (Applicable only when deployed using <strong><em>GlassFish</em></strong>). AdderService <strong><em>Web Service</em></strong> Tester page shown below will open in the browser.</p>
<p>Enter the integer values in the textbox of the test page and click on add2Numbers button. This will lead to the result page as shown below.</p>
<p><a href="http://www.javabeat.net/wp-content/uploads/2008/08/8.png"><img class="aligncenter size-medium wp-image-933" title="8" alt="" src="http://www.javabeat.net/wp-content/uploads/2008/08/8-300x108.png" width="300" height="108" /></a></p>
<h2>Summary</h2>
<p>In this article you have learnt how to develop a <strong><em>web service</em></strong> using <strong><em>Netbeans 6.1</em></strong> and deploy the service in <strong><em>GlassFish</em></strong> application server. This article doesnot cover the creation of stubs using <strong>Netbeans 6.1</strong> IDE. There are many ways to create stubs to test the web service. So keep learning. This is not the end, Still miles to go.</p>
<div class="wpInsert wpInsertInPostAd wpInsertBelow" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* JB-Footer-LU 468x15 */
google_ad_slot = "8789107210";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>]]></content:encoded>
			<wfw:commentRss>http://www.javabeat.net/2008/08/jax-ws-web-services-in-netbeans-6-1/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Accessing Web Services from JSF applications</title>
		<link>http://www.javabeat.net/2007/11/accessing-web-services-from-jsf-applications/</link>
		<comments>http://www.javabeat.net/2007/11/accessing-web-services-from-jsf-applications/#comments</comments>
		<pubDate>Sat, 10 Nov 2007 01:34:16 +0000</pubDate>
		<dc:creator>krishnas</dc:creator>
				<category><![CDATA[Java Server Faces (JSF)]]></category>
		<category><![CDATA[Webservices]]></category>

		<guid isPermaLink="false">http://www.javabeat.net/?p=2302</guid>
		<description><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><p>1) Introduction In this technical article, let us see how it is possible to access Web Services from JSF Applications. JSF Application resides in the Web Tier of a typical Enterprise Application, whereas Web Services are External Services that reside in the Application Tier. We make use of Java EE 5 for developing the Sample [...]</p>]]></description>
				<content:encoded><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><div class="wpInsert wpInsertInPostAd wpInsertLeft" style="float: left; margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Rect */
google_ad_slot = "9976259118";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><h2>1) Introduction</h2>
<p align="justify">In this technical article, let us see how it is possible to access <em><strong>Web Services</strong></em> from <em><strong>JSF Applications</strong></em>. JSF Application resides in the <em><strong>Web Tier</strong></em> of a typical Enterprise Application, whereas Web Services are <em><strong>External Services</strong></em> that reside in the <em><strong>Application Tier</strong></em>. We make use of Java EE 5 for developing the Sample Application in the final section of this article. It is assumed that readers have sufficient knowledge of JSF and Web Services before continuing this article. They also can have a glance over the introductory JavaBeat article on <a href="http://www.javabeat.net/2007/05/introduction-to-java-server-faces/">Java Server Faces</a> before proceeding with this.</p>
<h2 id="Web Services">2) Web Services</h2>
<h3>2.1) Introduction</h3>
<p align="justify"><em><strong>Web Services</strong></em> have been there in the software market over a decade of years and they are gaining more popularity in the recent years. Web Services provide an integration layer between two <em><strong>heterogeneous Applications</strong></em>. With Web Services, it is now possible to access a Java Application that is running in some remote machine with the client being any of the compliant languages like C, C++ or C#. This ensures that Web Services promote <em><strong>language interoperability</strong></em>. It is not necessary that both the Server and Client Application must be running in the same platform, thereby making it platform independent. Web Services alone is not a standard, instead it is a combination of several standards like <em><strong>SOAP</strong></em>, <em><strong>WSDL</strong></em> etc.</p>
<blockquote><p><span style="text-decoration: underline;"><strong>also read:</strong></span></p>
<ul>
<li><a title="Permanent Link to Introduction to Java Server Faces" href="http://www.javabeat.net/2007/05/introduction-to-java-server-faces/" rel="bookmark">Introduction to Java Server Faces</a></li>
<li><a title="Permanent Link to Request Processing Lifecycle phases in JSF" href="http://www.javabeat.net/2007/11/request-processing-lifecycle-phases-in-jsf/" rel="bookmark">Request Processing Lifecycle phases in JSF</a></li>
<li><a title="Permanent Link to Accessing Web Services from JSF applications" href="http://www.javabeat.net/2007/11/accessing-web-services-from-jsf-applications/" rel="bookmark">Accessing Web Services from JSF applications</a></li>
<li><a title="Permanent Link to Navigation model in JSF" href="http://www.javabeat.net/2007/11/navigation-model-in-jsf/" rel="bookmark">Navigation model in JSF</a></li>
</ul>
</blockquote>
<h3>2.2) SOAP</h3>
<p align="justify"><em><strong>SOAP</strong></em> stands for <em><strong>Simple Object Access Protocol</strong></em> and this is used in Web Services for transmitting messages between the Client and the Server. Technically, a SOAP message is in <em><strong>Xml format</strong></em> that conforms to a well defined schema. It means that a Client Application will construct its request in a SOAP message and send the message to the Server. The Server after unpacking the SOAP message will analyze the type of request and will return a suitable response in the form of a SOAP message.</p>
<p align="justify">Given below is a sample illustrating the structure of a Sample SOAP message,</p>
<p><strong>soap.xml</strong></p>
<pre class="brush: java; title: ; notranslate">&lt;Soap:Envelope
xmlns:Soap=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot;&gt;

    &lt;Soap:Header&gt;
        ...
    &lt;/Soap:Header&gt;

    &lt;Soap:Header&gt;
        ...
    &lt;/Soap:Header&gt;

    &lt;Soap:Body xmlns:MyData=&quot;http://mydata.com&quot;&gt;
    &lt;/Soap:Body&gt;

&lt;/Soap:Envelope&gt;

</pre>
<p align="justify">The SOAP message has an outer core called the <em><strong>SOAP Envelope</strong></em> followed by optional <em><strong>SOAP Headers</strong></em>. Following the SOAP Headers is the SOAP Body which will contain the Application that needs to be processed.</p>
<h3>2.3) WSDL</h3>
<p align="justify">WSDL stands for <em><strong>Web Service Description Language</strong></em> and this is the Client facing interface for accessing the Web Service. A typical WSDL file, which is also in Xml format, will list down all the possible Web Service that can be accessed over the Internet. Not only it will list down all the Web Services, but also the various supported operations that a particular Web Service will support.</p>
<h2 id="Using Web Services in JSF Application">3) Using Web Services in JSF Application</h2>
<h3>3.1) Introduction</h3>
<p align="justify">In this section, let us develop a <em><strong>Simple Hello Web Service</strong></em> that can be accessed by a <em><strong>JSF Application</strong></em>. As we are aware that in a JSF Application, the business processing is usually done by the <em><strong>Managed Beans</strong></em>. It is also possible that a Managed Bean can delegate its functionality to an <em><strong>External Service</strong></em> like an <em><strong>Enterprise Bean</strong></em> or a <em><strong>Web Service</strong></em>.</p>
<h3>3.2) Coding the Hello Web Service</h3>
<p><strong>HelloWebService.java</strong></p>
<pre class="brush: java; title: ; notranslate">package hello;

import javax.jws.HandlerChain;
import javax.jws.WebMethod;
import javax.jws.WebService;

@WebService()
@HandlerChain(file = &quot;HelloWebService_handler.xml&quot;)
public class HelloWebService
{
    @WebMethod
    public String sayHello()
    {
        return &quot;Hello&quot;;
    }
}
</pre>
<p align="justify">The above code defines a Hello Web Service by name <code>'HelloWebService'</code>. Since the Application is developed using J2EE 5.0 standard, we have taken the full utilization of Annotation for annotating our declarations. Let us get into the details now. To qualify an implementation class as a Web Service we have simply used the Annotation <code>'WebService'</code>. That is all which is needed for the Application Server to treat this class as a Web Service. Let us look into the <em><strong>Handler Chain</strong></em> in the next section. To qualify an operation as a Web Service operation, we have to use the Annotation <code>'WebMethod'</code>.</p>
<h3>3.2) Handler Chains</h3>
<p align="justify">It is possible to attach any number of <em><strong>Handler Chains</strong></em> for a Web Service. To say in simple words, a <em><strong>Handler Chain</strong></em> defines the sequence of steps that used to happen when the request from the Client (in the form of SOAP message), after passing through the various nodes, goes to the ultimate Server for getting processed. Since a Handler Chain is not dependent of the type of the protocol used, we can define a handler Chain for any protocol. Just to make use of the Handler Chain in this Application, we have defined Custom Handler Chain and have referenced the same in the Hello Web Service with the help of HandlerChain Annotation.</p>
<p align="justify">Given below is the declaration of a Simple Standard Chain,</p><div class="wpInsert wpInsertInPostAd wpInsertMiddle" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Middle-Med-Rect */
google_ad_slot = "7805667846";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
<p><strong>HelloMH.java</strong></p>
<pre class="brush: java; title: ; notranslate">package hello;

import java.util.Collections;
import java.util.Set;
import javax.xml.namespace.QName;
import javax.xml.soap.SOAPMessage;
import javax.xml.ws.handler.MessageContext;
import javax.xml.ws.handler.soap.SOAPHandler;
import javax.xml.ws.handler.soap.SOAPMessageContext;

public class HelloMH implements SOAPHandler&lt;SOAPMessageContext&gt;
{
    public boolean handleMessage(SOAPMessageContext messageContext)
    {
        SOAPMessage msg = messageContext.getMessage();
        return true;
    }

    public Set&lt;QName&gt; getHeaders()
    {
        return Collections.EMPTY_SET;
    }

    public boolean handleFault(SOAPMessageContext messageContext)
    {
        return true;
    }

    public void close(MessageContext context)
    {
    }
}
</pre>
<p align="justify">The definition of the <em><strong>Handler Chain</strong></em> is defined in the following Xml file and this Xml file is referenced in the <code>HandlerChain</code> Annotation while defining the Web Service.</p>
<p><strong>HelloWebService_handler.xml</strong></p>
<pre class="brush: java; title: ; notranslate">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;

    &lt;handler-chains xmlns=&quot;http://java.sun.com/xml/ns/javaee&quot;&gt;
        &lt;handler-chain&gt;
            &lt;handler&gt;
            &lt;handler-name&gt;hello.HelloMH&lt;/handler-name&gt;
            &lt;handler-class&gt;hello.HelloMH&lt;/handler-class&gt;
        &lt;/handler&gt;
    &lt;/handler-chain&gt;

&lt;/handler-chains&gt;
</pre>
<h3>3.3) Hello WSDL File</h3>
<p align="justify">As mentioned earlier, a <em><strong>WSDL</strong></em> contains the definitions for various Web Services along with its supported operation. Precisely, all the request and the response data from the Client and the Server will be modeled as <em><strong>messages</strong></em> in the WSDL file. A <em><strong>port type</strong></em> is a WSDL file which defines a set of operations along with the input and the output messages that they will take. Having defined about the various operations along with its <em><strong>messages</strong></em>, how they are bound with a specific protocol is defined by the <code>'binding'</code> element. Finally the <code>'service'</code> element along with its <code>'port'</code> and the <code>'address'</code> elements will define the ports that are accessible by the clients and the URL through which these Web Services can be invoked.</p>
<p align="justify">The following code snippet is the definition of the Hello WSDL file,</p>
<p><strong>HelloWebServiceService.wsdl</strong></p>
<pre class="brush: java; title: ; notranslate">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;

&lt;definitions xmlns=&quot;http://schemas.xmlsoap.org/wsdl/&quot;
        xmlns:tns=&quot;http://hello/&quot;
        xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot;
        xmlns:soap=&quot;http://schemas.xmlsoap.org/wsdl/soap/&quot;
        targetNamespace=&quot;http://hello/&quot; name=&quot;HelloWebServiceService&quot;&gt;

&lt;types&gt;
    &lt;xsd:schema&gt;
    &lt;xsd:import namespace=&quot;http://hello/&quot;
           schemaLocation=&quot;HelloWebServiceService_schema.xsd&quot;
           xmlns:wsdl=&quot;http://schemas.xmlsoap.org/wsdl/&quot;
           xmlns:soap12=&quot;http://schemas.xmlsoap.org/wsdl/soap12/&quot;/&gt;
    &lt;/xsd:schema&gt;
&lt;/types&gt;

&lt;message name=&quot;sayHello&quot;&gt;
    &lt;part name=&quot;parameters&quot; element=&quot;tns:sayHello&quot;/&gt;
&lt;/message&gt;
&lt;message name=&quot;sayHelloResponse&quot;&gt;
    &lt;part name=&quot;parameters&quot; element=&quot;tns:sayHelloResponse&quot;/&gt;
&lt;/message&gt;

&lt;portType name=&quot;HelloWebService&quot;&gt;
    &lt;operation name=&quot;sayHello&quot;&gt;
        &lt;input message=&quot;tns:sayHello&quot;/&gt;
        &lt;output message=&quot;tns:sayHelloResponse&quot;/&gt;
    &lt;/operation&gt;
&lt;/portType&gt;

&lt;binding name=&quot;HelloWebServicePortBinding&quot; type=&quot;tns:HelloWebService&quot;&gt;
    &lt;soap:binding transport=&quot;http://schemas.xmlsoap.org/soap/http&quot; style=&quot;document&quot;/&gt;
        &lt;operation name=&quot;sayHello&quot;&gt;
            &lt;soap:operation soapAction=&quot;&quot;/&gt;
            &lt;input&gt;
                &lt;soap:body use=&quot;literal&quot;/&gt;
            &lt;/input&gt;
            &lt;output&gt;
                &lt;soap:body use=&quot;literal&quot;/&gt;
            &lt;/output&gt;
        &lt;/operation&gt;
&lt;/binding&gt;

&lt;service name=&quot;HelloWebServiceService&quot;&gt;
    &lt;port name=&quot;HelloWebServicePort&quot;
          binding=&quot;tns:HelloWebServicePortBinding&quot;&gt;
        &lt;soap:address
          location=&quot;http://indpd218:8080/HelloWS/HelloWebServiceService&quot;
       xmlns:wsdl=&quot;http://schemas.xmlsoap.org/wsdl/&quot;
        xmlns:soap12=&quot;http://schemas.xmlsoap.org/wsdl/soap12/&quot;/&gt;
    &lt;/port&gt;
&lt;/service&gt;

&lt;/definitions&gt;
</pre>
<h3>3.4) JSF Managed Bean</h3>
<p><strong>HelloManagedBean.java</strong></p>
<pre class="brush: java; title: ; notranslate">package hello;
public class HelloManagedBean {

    public HelloManagedBean()
    {
    }

    public void callWebService()
    {
        try
        {
            hello.client.HelloWebServiceService service =
                new hello.client.HelloWebServiceService();
            hello.client.HelloWebService port =
                service.getHelloWebServicePort();

            java.lang.String result = port.sayHello();
            System.out.println(&quot;Result = &quot;+result);
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    }
}
</pre>
<p align="justify">A <em><strong>JSF Managed Bean</strong></em> will be triggered whenever an Event happens in the Client side like the Click of a Button, or hyperlink etc. So, invoking the business logic defined for the Web Service in this place will be more ideal. In the above Managed Bean, we have defined a method called <code>callWebService()</code> within which we have coded the logic for accessing the Web Service. Note the usage of the classes <code>HelloWebServiceService</code> and <code>HelloWebService</code>. The classes (or Web Service skeletons) will be generated by a standard IDE (like NetBeans) when given with a WSDL file.</p>
<h3>3.5) JSF Configuration File</h3>
<p align="justify">The following is the definition of the <code>HelloManagedBean</code> that we saw just now. We have given an identifier called <code>'helloManagedBean'</code> through the attribute <code>'managed-bean-name'</code> element. Note that the <code>'managed-bean-class'</code> element should point to the fully qualified name of the Managed Bean.</p>
<p><strong>faces-config.xml</strong></p>
<pre class="brush: java; title: ; notranslate">&lt;?xml version='1.0' encoding='UTF-8'?&gt;

&lt;faces-config version=&quot;1.2&quot;
xmlns=&quot;http://java.sun.com/xml/ns/javaee&quot;
xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
xsi:schemaLocation=&quot;http://java.sun.com/xml/ns/javaee

http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd&quot;&gt;

&lt;managed-bean&gt;
    &lt;managed-bean-name&gt;helloManagedBean&lt;/managed-bean-name&gt;
    &lt;managed-bean-class&gt;hello.HelloManagedBean&lt;/managed-bean-class&gt;
    &lt;managed-bean-scope&gt;request&lt;/managed-bean-scope&gt;
&lt;/managed-bean&gt;

&lt;/faces-config&gt;
</pre>
<h3>3.6) Accessing the Web Service</h3>
<p><strong>index.jsp</strong></p>
<pre class="brush: java; title: ; notranslate">&lt;%@page contentType=&quot;text/html&quot;%&gt;
&lt;%@page pageEncoding=&quot;UTF-8&quot;%&gt;

&lt;%@taglib prefix=&quot;f&quot; uri=&quot;http://java.sun.com/jsf/core&quot;%&gt;
&lt;%@taglib prefix=&quot;h&quot; uri=&quot;http://java.sun.com/jsf/html&quot;%&gt;

&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;
&quot;http://www.w3.org/TR/html4/loose.dtd&quot;&gt;

&lt;html&gt;

&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=UTF-8&quot;&gt;
&lt;title&gt;Accessing Web Services from JavaServer Faces&lt;/title&gt;
&lt;/head&gt;

	&lt;body&gt;
	&lt;f:view&gt;
	&lt;h1&gt;
	&lt;h:outputText
        value=&quot;Accessing Web Services from JavaServer Faces&quot; /&gt;
	&lt;/h1&gt;

	&lt;h:commandButton value = &quot;Invoke Web Service&quot;
		action = &quot;#{helloManagedBean.callWebService}&quot;&gt;
	&lt;/h:commandButton&gt;

	&lt;/f:view&gt;
	&lt;/body&gt;

&lt;/html&gt;
</pre>
<p align="justify">Since we have wrapped the Hello Web Service within the Managed Bean declaration, invoking the Web Service becomes as easy as defining the JSF Method Expression. In the above code snippet, we have defined a Command Button and the value of the &#8216;action&#8217; attribute is pointing to &#8216;#{helloManagedBean.callWebService}&#8217;</p>
<h2>4) Conclusion</h2>
<p align="justify">This article had guided in using External Services like Web Services from JSF Applications. It initially went through Web Services explaining the various standards related to Web Services like SOAP and WSDL. Then the later half of the article showed the steps involved in integration Web Services in a JSF Application.</p>
<div class="wpInsert wpInsertInPostAd wpInsertBelow" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* JB-Footer-LU 468x15 */
google_ad_slot = "8789107210";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>]]></content:encoded>
			<wfw:commentRss>http://www.javabeat.net/2007/11/accessing-web-services-from-jsf-applications/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Creating Webservice using JBoss and Eclipse Europa</title>
		<link>http://www.javabeat.net/2007/10/creating-webservice-using-jboss-and-eclipse-europa/</link>
		<comments>http://www.javabeat.net/2007/10/creating-webservice-using-jboss-and-eclipse-europa/#comments</comments>
		<pubDate>Fri, 12 Oct 2007 11:39:44 +0000</pubDate>
		<dc:creator>krishnas</dc:creator>
				<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[JBoss]]></category>
		<category><![CDATA[Webservices]]></category>
		<category><![CDATA[Eclipse Europa]]></category>
		<category><![CDATA[Webservice]]></category>

		<guid isPermaLink="false">http://www.javabeat.net/?p=110</guid>
		<description><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><p>This article will introduce you to JBoss Webservice(JAX-WS). Here you will be knowing how to use the annotations and create a web service to deploy in JBoss. Since JBoss comes with JAX-WS jars inbuilt, we will not be adding any jars in addition for this article. This article will also give you a example code [...]</p>]]></description>
				<content:encoded><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><div class="wpInsert wpInsertInPostAd wpInsertLeft" style="float: left; margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Rect */
google_ad_slot = "9976259118";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><p><span style="font-size: 13px;">This article will introduce you to </span><strong style="font-size: 13px;"><em>JBoss Webservice</em></strong><strong style="font-size: 13px;"><em>(JAX-WS)</em></strong><span style="font-size: 13px;">. Here you will be knowing how to use the </span><strong style="font-size: 13px;"><em>annotations</em></strong><span style="font-size: 13px;"> and create a web service to deploy in JBoss. Since JBoss comes with </span><strong style="font-size: 13px;"><em>JAX-WS</em></strong><span style="font-size: 13px;"> jars inbuilt, we will not be adding any jars in addition for this article. This article will also give you a example code and walk you through the code. This will also explain creation of </span><strong style="font-size: 13px;"><em>dynamic web project</em></strong><span style="font-size: 13px;"> (not elaborated) and </span><strong style="font-size: 13px;"><em>configuration of JBoss server</em></strong><span style="font-size: 13px;"> to it.</span></p>
<p>You can also get <strong><em>JBossws</em></strong> download separately and create a webservice and deploy it in your preferred application server. Since we are using JBoss for this article we will not be covering this information here.</p>
<h2>Software Used in <strong><em>Configuring JBossws</em></strong></h2>
<ul>
<li><strong><em>JBoss Application Server 4.0.5.GA</em></strong>.</li>
<li><strong><em>Eclipse Europa</em></strong> (WTP all in one pack)</li>
<li><strong><em>JDK 1.5.x</em></strong></li>
</ul>
<h2>Pre-Requirements to Learn JBossWs and follow this article.</h2>
<ul>
<li>Should have <strong><em>Java</em></strong> knowledge.</li>
<li>Should know how to use <strong><em>Eclipse</em></strong>. (Creating web projects in Eclipse)</li>
<li>Should have basic knowledge of <strong><em>webservice</em></strong>.</li>
</ul>
<h2>Where to get the JBossWs from?</h2>
<p>You can download the software from the following URL:</p>
<ul>
<li><strong><em>JBoss Application Server 4.0.5.GA</em></strong>. == <a href="http://labs.jboss.com/" target="_blank">http://labs.jboss.com/</a></li>
<li><strong><em>Eclipse Europa</em></strong> (WTP all in one pack)== <a href="http://eclipse.org" target="_blank">http://eclipse.org</a></li>
<li><strong><em>JDK 1.5.x</em></strong> == <a href="http://java.sun.com" target="_blank">http://java.sun.com</a></li>
</ul>
<h2>Defining JBoss server in Eclipse</h2>
<p>First thing what you have to do is to <strong><em>define JBoss server in Eclipse</em></strong>. The steps below will explain how to define JBoss server in Eclipse.</p>
<ul>
<li>Step 1 : Open <strong><em>Eclipse WTP all in one pack</em></strong> in a new work space.</li>
<li>Step 2 : Change the perspective to <strong><em>J2EE Perspective</em></strong> if it is not currently in J2EE Perspective.</li>
<li>Step 3 : Once the Perspective is changed to <strong><em>J2EE</em></strong>, you can see a tab called <strong><em>Servers</em></strong> in the bottom right panel along with Problems, Tasks, Properties.</li>
<li>Step 4 : If the Servers tab is not found. Go to Eclipse <strong><em>menu : Windows &gt; Show view</em></strong> and click on Servers, so that Server tab will be displayed.</li>
<li>Step 5 : Go to Servers tab window and right click the mouse. You will get a pop up menu called &#8220;New&#8221;.</li>
<li>Step 6 : Clicking on the New menu you will get one more pop up called <strong><em>&#8220;Server&#8221;</em></strong>. Click on it.</li>
<li>Step 7 : Now you will get <strong><em>Define New Server Wizard</em></strong>.</li>
<li>Step 8 : In the wizard there are options to define many servers. One among them is <strong><em>JBoss</em></strong>. Click on JBoss and Expand the tree.</li>
<li>Step 9 : Select <strong><em>JBoss v 4.0</em></strong> and click next.</li>
<li>Step 10 : Now give the <strong><em>JDK</em></strong> directory and <strong><em>JBoss home</em></strong> directory. Click Next.</li>
<li>Step 11 : Now the wizard will show you the default Address, port, etc., Leave it as it is and click on Next.</li>
<li>Step 12 : Click on finish.</li>
<li>Step 13 : Now you can see the <strong><em>JBoss server</em></strong> listed in the Servers window and the status is Stopped.</li>
<li>Step 14 : JBoss server is now defined in Eclipse now and its ready to use from with in <strong><em>Eclipse IDE</em></strong>.</li>
</ul>
<h2>Creating a Dynamic Web Application Project</h2>
<p>Now it is time to <strong><em>create a web application</em></strong> in order to <strong><em>Expose a method as a Web service</em></strong>.</p>
<p>Create a <strong><em>Dynamic Web Application Project in eclipse</em></strong> by selecting the <strong><em>JBoss server</em></strong> what we have defined in the Eclipse IDE as the default server for the project. (We assume that who ever is reading this article knows how to create a dynamic web application in Eclipse, So that part is not detailed out here).</p>
<p>Once the <strong><em>JBoss server</em></strong> is selected as the server for the web applications. <strong><em>All the libraries existing in JBoss will be selected and used by eclipse in the Build Path</em></strong>. So no need to add any extra jar files for our work.</p>
<p>Now we will start with a <strong><em>Java code</em></strong>:</p>
<p>This is a simple <strong><em>Java code</em></strong> and does not have any thing to do with <strong><em>Webservices</em></strong>.</p>
<h3>JBossWs Code sample without annotations: (TestWs.java)</h3>
<p>Our Java code will have a single method called &#8220;greet&#8221;. Its functionality will be just to accept a string and return the same prefixed with &#8220;Hello&#8221;.</p>
<pre class="brush: java; title: ; notranslate">package com.test.dhanago;

public class TestWs
{
   /**
    * This method will accept a string and prefix with Hello.
    *
    * @param name
    * @return
    */
   public String greet( String name )
   {
      return &quot;Hello&quot; + name;
   }
}</pre>
<p>We will add <strong><em>annotations</em></strong> to the above code and modify the code like below:</p>
<h3>JBossWs Code sample with annotations: (TestWs.java)</h3>
<pre class="brush: java; title: ; notranslate">package com.test.dhanago;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;

/**
 * This is a webservice class exposing a method called greet which takes a
 * input parameter and greets the parameter with hello.
 *
 * @author dhanago
 */

/*
 * @WebService indicates that this is webservice interface and the name
 * indicates the webservice name.
 */
@WebService(name = &quot;TestWs&quot;)
/*
 * @SOAPBinding indicates binding information of soap messages. Here we have
 * document-literal style of webservice and the parameter style is wrapped.
 */
@SOAPBinding
   (
         style = SOAPBinding.Style.DOCUMENT,
         use = SOAPBinding.Use.LITERAL,
         parameterStyle = SOAPBinding.ParameterStyle.WRAPPED
    )
public class TestWs
{
   /**
    * This method takes a input parameter and appends &quot;Hello&quot; to it and
    * returns the same.
    *
    * @param name
    * @return
    */
   @WebMethod
   public String greet( @WebParam(name = &quot;name&quot;)
   String name )
   {
      return &quot;Hello&quot; + name;
   }

}</pre>
<h3>JBossWs annotations Walk Through</h3>
<pre class="brush: java; title: ; notranslate">@WebService(name = &quot;TestWs&quot;)</pre>
<p>Here, <strong><em>@WebService </em></strong>Indicates that this is a webservice class. <strong><em>name = &#8220;TestWs&#8221; </em></strong>Indicates the webservice name.</p>
<pre class="brush: java; title: ; notranslate">@SOAPBinding
   (
         style = SOAPBinding.Style.DOCUMENT,
         use = SOAPBinding.Use.LITERAL,
         parameterStyle = SOAPBinding.ParameterStyle.WRAPPED
    )</pre>
<p>Here, <strong><em>@SOAPBinding </em></strong>Indicates binding information of <strong><em>soap messages</em></strong>. The properties below them indicates the <strong><em>style of web service</em></strong>, Here it is <strong><em>document-literal style</em></strong>. And <strong><em>parameter style is Wrapped</em></strong>.</p>
<p>Here, <strong><em>@WebMethod </em></strong>Indicates this is a method <strong><em>exposed as web service</em></strong>. <strong><em>@WebParam </em></strong>Indicates the <strong><em>parameter name to be used in soap message</em></strong>.</p>
<h2>JBossWs Deployment Descriptor</h2>
<p>Once the code is ready and compiled. You have modify the web.xml file located in WEB-INF folder.</p><div class="wpInsert wpInsertInPostAd wpInsertMiddle" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Middle-Med-Rect */
google_ad_slot = "7805667846";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
<p>Modify the <strong><em>web.xml</em></strong> file like below. (web.xml)</p>
<pre class="brush: java; title: ; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;web-app xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
    xmlns=&quot;http://java.sun.com/xml/ns/javaee&quot;
    xmlns:web=&quot;http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd&quot;
    xsi:schemaLocation=&quot;http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd&quot;
    id=&quot;WebApp_ID&quot; version=&quot;2.5&quot;&gt;
    &lt;display-name&gt;TestWS&lt;/display-name&gt;
    &lt;servlet&gt;
        &lt;servlet-name&gt;TestWs&lt;/servlet-name&gt;
        &lt;servlet-class&gt;com.test.dhanago.TestWs&lt;/servlet-class&gt;
        &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
    &lt;/servlet&gt;
    &lt;servlet-mapping&gt;
        &lt;servlet-name&gt;TestWs&lt;/servlet-name&gt;
        &lt;url-pattern&gt;/TestWs&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
    &lt;session-config&gt;
        &lt;session-timeout&gt;30&lt;/session-timeout&gt;
    &lt;/session-config&gt;
    &lt;welcome-file-list&gt;
        &lt;welcome-file&gt;index.html&lt;/welcome-file&gt;
        &lt;welcome-file&gt;index.htm&lt;/welcome-file&gt;
        &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt;
        &lt;welcome-file&gt;default.html&lt;/welcome-file&gt;
        &lt;welcome-file&gt;default.htm&lt;/welcome-file&gt;
        &lt;welcome-file&gt;default.jsp&lt;/welcome-file&gt;
    &lt;/welcome-file-list&gt;
&lt;/web-app&gt;
</pre>
<h2><strong><em>Deploying the JBoss web service application</em></strong></h2>
<p>Once this is done, its time to build and deploy the application in <strong><em>JBoss Application server</em></strong>.<br />
Once every thing is compiled with out any errors. And if you have enabled the <strong><em>Auto build unctionality of the Eclipse IDE</em></strong>, You have already done with building the application. If the auto build functionality of eclipse is not enabled, then right click on the project and build the project using build option.</p>
<p>Go to Servers window and right click on the <strong><em>JBoss server</em></strong> listed over there and select Run.<br />
Wait for server to start. Once it starts, right click on the server listing. You can find a option called <strong><em>&#8220;Add and Remove Project&#8221;</em></strong>. Click on the option. You will get a wizard where you can select your projects to move to right and <strong><em>configure with server</em></strong>. Once you moved your project. Click on finish.</p>
<p>Once it is done, you can find that the project is again build and moved to server default deployment folder automatically.</p>
<p>Console will display you like below.</p>
<pre class="brush: java; title: ; notranslate">Buildfile: D:\ec2\eclipse\plugins\org.eclipse.jst.server.generic.jboss_1.5.102.v20070608\buildfiles\jboss323.xml
deploy.j2ee.web:
      [jar] Building jar: D:\validation\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\Tws.war
     [move] Moving 1 file to D:\MyBoss\jboss-4.0.5.GA_ws121\server\default\deploy
BUILD SUCCESSFUL
Total time: 10 seconds</pre>
<p>The dynamic web application i created is with the name &#8220;Tws&#8221;. So the build has created Tws.war and moved it to the default deploy folder of the JBoss server.</p>
<p>To make sure web service is started once it is deployed in the JBoss console you can find the log like below.</p>
<pre class="brush: java; title: ; notranslate">13:57:52,306 INFO  [ServiceEndpointManager] WebService started: http://:8080/Tws/TestWs</pre>
<p>To view the WSDL follow the link http://&lt;machine name&gt;:8080/Tws/TestWs?wsdl</p>
<p>To see the list of webservices deployed in your JBoss Application server follow the link <a href="http://localhost:8080/jbossws">http://localhost:8080/jbossws</a>. This browser console will have link to see your deployed webservices and their <strong><em>WSDL</em></strong> files.</p>
<h3>JBossWs Browser Console.</h3>
<p><a href="http://www.javabeat.net/wp-content/uploads/2007/10/1.jpg"><img class="aligncenter size-medium wp-image-889" title="1" alt="" src="http://www.javabeat.net/wp-content/uploads/2007/10/1-300x178.jpg" width="300" height="178" /></a>Clicking on <strong><em>View a list of deployed services</em></strong> will list you the deployed web services. In our case we will get the following screen where we can see the registered service endpoints.</p>
<p><a href="http://www.javabeat.net/wp-content/uploads/2007/10/2.jpg"><img class="aligncenter size-medium wp-image-890" title="2" alt="" src="http://www.javabeat.net/wp-content/uploads/2007/10/2-300x190.jpg" width="300" height="190" /></a>Here in this screen you can see the <strong><em>ServiceEndpointAddress</em></strong> link which will take you to the <strong><em>WSDL</em></strong> file.</p>
<p>You can also find the <strong><em>WSDL</em></strong> file in the following path:<br />
&lt;jboss_path&gt;\server\default\data\wsdl\&lt;project_name&gt;.war\&lt;filename&gt;.wsdl</p>
<p>You can generate the <strong><em>client stubs</em></strong> using this file and access the web service. Creating the client stubs to access the web service is out of scope of this article.</p>
<h2>The WSDL file generated using JBossWs is shown below:</h2>
<pre class="brush: java; title: ; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;definitions name=&quot;TestWsService&quot; targetNamespace=&quot;http://dhanago.test.com/&quot; xmlns:tns=&quot;http://dhanago.test.com/&quot; xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot; xmlns:soap=&quot;http://schemas.xmlsoap.org/wsdl/soap/&quot; xmlns=&quot;http://schemas.xmlsoap.org/wsdl/&quot;&gt;
  &lt;types&gt;
    &lt;xs:schema targetNamespace=&quot;http://dhanago.test.com/&quot; version=&quot;1.0&quot; xmlns:tns=&quot;http://dhanago.test.com/&quot; xmlns:xs=&quot;http://www.w3.org/2001/XMLSchema&quot;&gt;
   &lt;xs:element name=&quot;greet&quot; type=&quot;tns:greet&quot;/&gt;
   &lt;xs:element name=&quot;greetResponse&quot; type=&quot;tns:greetResponse&quot;/&gt;
   &lt;xs:complexType name=&quot;greet&quot;&gt;
    &lt;xs:sequence&gt;
     &lt;xs:element minOccurs=&quot;0&quot; name=&quot;name&quot; type=&quot;xs:string&quot;/&gt;
    &lt;/xs:sequence&gt;
   &lt;/xs:complexType&gt;
   &lt;xs:complexType name=&quot;greetResponse&quot;&gt;
    &lt;xs:sequence&gt;
     &lt;xs:element minOccurs=&quot;0&quot; name=&quot;return&quot; type=&quot;xs:string&quot;/&gt;
    &lt;/xs:sequence&gt;
   &lt;/xs:complexType&gt;
  &lt;/xs:schema&gt;
  &lt;/types&gt;
  &lt;message name=&quot;TestWs_greet&quot;&gt;
    &lt;part name=&quot;greet&quot; element=&quot;tns:greet&quot;/&gt;
  &lt;/message&gt;
  &lt;message name=&quot;TestWs_greetResponse&quot;&gt;
    &lt;part name=&quot;greetResponse&quot; element=&quot;tns:greetResponse&quot;/&gt;
  &lt;/message&gt;
  &lt;portType name=&quot;TestWs&quot;&gt;
    &lt;operation name=&quot;greet&quot; parameterOrder=&quot;greet&quot;&gt;
      &lt;input message=&quot;tns:TestWs_greet&quot;/&gt;
      &lt;output message=&quot;tns:TestWs_greetResponse&quot;/&gt;
    &lt;/operation&gt;
  &lt;/portType&gt;
  &lt;binding name=&quot;TestWsBinding&quot; type=&quot;tns:TestWs&quot;&gt;
    &lt;soap:binding style=&quot;document&quot; transport=&quot;http://schemas.xmlsoap.org/soap/http&quot;/&gt;
    &lt;operation name=&quot;greet&quot;&gt;
      &lt;soap:operation soapAction=&quot;&quot;/&gt;
      &lt;input&gt;
        &lt;soap:body use=&quot;literal&quot;/&gt;
      &lt;/input&gt;
      &lt;output&gt;
        &lt;soap:body use=&quot;literal&quot;/&gt;
      &lt;/output&gt;
    &lt;/operation&gt;
  &lt;/binding&gt;
  &lt;service name=&quot;TestWsService&quot;&gt;
    &lt;port name=&quot;TestWsPort&quot; binding=&quot;tns:TestWsBinding&quot;&gt;
      &lt;soap:address location=&quot;http://EC3-NOR-124251:8080/Tws/TestWs&quot;/&gt;
    &lt;/port&gt;
  &lt;/service&gt;
&lt;/definitions&gt;
</pre>
<h2>Summary</h2>
<p>This article is just a quick start to start with for developers who want to quickly proceed with <strong><em>JBoss web services</em></strong>. It is up to the developers interest to leverage on this and proceed further. This is not the only procedure to expose a web service in JBoss. There might be lot of ways to do that and this is one of the way. So don&#8217;t stop here and continue Exploring.</p>
<div class="wpInsert wpInsertInPostAd wpInsertBelow" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* JB-Footer-LU 468x15 */
google_ad_slot = "8789107210";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>]]></content:encoded>
			<wfw:commentRss>http://www.javabeat.net/2007/10/creating-webservice-using-jboss-and-eclipse-europa/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
