<?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>Apache CXF Web Services Development Book Site</title>
	<atom:link href="http://cxf.soaweb.co.in/index.php/feed/" rel="self" type="application/rss+xml" />
	<link>http://cxf.soaweb.co.in</link>
	<description>Services development simplified</description>
	<lastBuildDate>Sat, 03 Jul 2010 13:53:02 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Comparing Spring webservices and CXF</title>
		<link>http://cxf.soaweb.co.in/index.php/2010/04/02/comparing-spring-webservices-and-cxf/</link>
		<comments>http://cxf.soaweb.co.in/index.php/2010/04/02/comparing-spring-webservices-and-cxf/#comments</comments>
		<pubDate>Fri, 02 Apr 2010 07:28:01 +0000</pubDate>
		<dc:creator>Naveen</dc:creator>
				<category><![CDATA[CXF Services Book]]></category>
		<category><![CDATA[comparison]]></category>
		<category><![CDATA[cxf and spring]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[web service frameworks]]></category>

		<guid isPermaLink="false">http://cxf.soaweb.co.in/?p=214</guid>
		<description><![CDATA[// 


Spring web services at a glance -
Spring web services is focused on creating contract-first document oriented web services. Spring web services, being a product of Spring, offer first class support of using Spring configurations and integrating with Spring framework.
Spring promotes contract-first development completely and provides an ability to plug-in various XML APIs (SAX, DOM, [...]]]></description>
			<content:encoded><![CDATA[<p><script type="text/javascript">// <![CDATA[
   google_ad_client = "pub-3843887054708077"; /* 468x15, created 6/2/10 */ google_ad_slot = "8275571625"; google_ad_width = 468; google_ad_height = 15;
// ]]&gt;</script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script></p>
<p><strong>Spring web services at a glance -</strong></p>
<p>Spring web services is focused on creating contract-first document oriented web services. Spring web services, being a product of Spring, offer first class support of using Spring configurations and integrating with Spring framework.</p>
<p>Spring promotes contract-first development completely and provides an ability to plug-in various XML APIs (SAX, DOM, STAXM, XOM, JDOM..) to handle XML messages. Using Spring web services, you can always ensure the XML contract (xml schemas) is marshaled correctly into Java objects. Spring web services support JAXB 1 and 2, Castor, XMLBeans, JiBX, and XStream as part of its XML Marshalling support.</p>
<p>Spring web-service provides options to secure web services using Acegi security and provides ability to encrypt/decrypt messages and support for webservices security standards.</p>
<p><strong>CXF at a glance –</strong></p>
<p>Apache CXF is an open source web service framework that provides an easy to use, standard-based programming model for developing web services. Web services can be implemented using different application protocols like SOAP, XML, JSON, RESTful HTTP, and support various transport protocols like HTTP or JMS (JavaMessage Service).</p>
<p>CXF supports both code-first and contract first development and provides first class support for using Spring configuration.  CXF supports all of the widely used web service specifications.</p>
<p>To get started with CXF, you can download a complementary chapter and index of Apache CFX Web Service Development book.</p>
<a class="downloadlink" href="http://cxf.soaweb.co.in/wp-content/plugins/download-monitor/download.php?id=2" title="Version 1.0 downloaded 291 times" >Sample Apache CXF Web Service Book Chapter</a>
<p><strong>Which one should I use ?</strong></p>
<p>The choice of selecting a web services stack depends on multiple factors like standards compliance, ease of development , deployment options, unit testing options, integration with leading frameworks like Spring, flexibility and extensibility and so on.</p>
<p>In my view, the strict enforcement on using contract first development only with spring web services can become a bottle neck, depending on your requirements.</p>
<p>There might be scenarios where you would want to use code-first development and can easily generate contracts (xml schemas) that way you intended. If you are aware of how Java objects are generated to XML and limitations associated with it, this would also help you to generate the right XML format.</p>
<p>CXF provides support for code first and contract first development, and provides ability to plug-in various flexible binding mechanisms. Leaving the choice of code-first and contract first development to a user based on their requirements is a big plus.  Using CXF, you could achieve what Spring web services offer today, although it doesn’t support the numerous XML API options and binding support offered by Spring web-services, but it should suffice for most of the requirements.</p>
<p><div class="amzshcs" id="amzshcs-0ffe1990b5c22a8e10d5ec748e774099"><div class="amzshcs-item" id="amzshcs-item-b8543e78f0aeb0dd818a17e03e0b28ed"> <a href="http://www.amazon.com/Apache-CXF-Web-Service-Development/dp/1847195407%3FSubscriptionId%3DAKIAJWQLRXGXNE5KBGJA%26tag%3Dsw0fd-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D1847195407"><img src="http://ecx.images-amazon.com/images/I/51Sstnuk-CL._SL160_.jpg" height="160" width="130" alt="Image of Apache CXF Web Service Development" title="Apache CXF Web Service Development" /></a> </div></div></p>
<div id="_mcePaste" style="overflow: hidden; position: absolute; left: -10000px; top: 670px; width: 1px; height: 1px;">&lt;a href=&#8221;http://www.amazon.com/gp/product/B0015T963C?ie=UTF8&amp;tag=sw0fd-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=B0015T963C&#8221;&gt;&lt;img border=&#8221;0&#8243; src=&#8221;41t7SWZ2vpL._SL160_.jpg&#8221;&gt;&lt;/a&gt;&lt;img src=&#8221;http://www.assoc-amazon.com/e/ir?t=sw0fd-20&amp;l=as2&amp;o=1&amp;a=B0015T963C&#8221; width=&#8221;1&#8243; height=&#8221;1&#8243; border=&#8221;0&#8243; alt=&#8221;" style=&#8221;border:none !important; margin:0px !important;&#8221; /&gt;</div>
<p><a href="http://www.amazon.com/gp/product/B0015T963C?ie=UTF8&amp;tag=sw0fd-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=B0015T963C"><img src="41t7SWZ2vpL._SL160_.jpg" border="0" alt="" /></a><img style="border:none !important; margin:0px !important;" src="http://www.assoc-amazon.com/e/ir?t=sw0fd-20&amp;l=as2&amp;o=1&amp;a=B0015T963C" border="0" alt="" width="1" height="1" /><br />
<script type="text/javascript">// <![CDATA[
   google_ad_client = "pub-3843887054708077"; /* 468x15, created 6/2/10 */ google_ad_slot = "8275571625"; google_ad_width = 468; google_ad_height = 15;
// ]]&gt;</script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script></p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Comparing+Spring+webservices+and+CXF+http://cxf.soaweb.co.in/?p=214" title="Post to Twitter"><img class="nothumb" src="http://cxf.soaweb.co.in/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Comparing+Spring+webservices+and+CXF+http://cxf.soaweb.co.in/?p=214" title="Post to Twitter">Tweet This Post</a> <a class="tt" href="http://delicious.com/post?url=http://cxf.soaweb.co.in/index.php/2010/04/02/comparing-spring-webservices-and-cxf/&amp;title=Comparing+Spring+webservices+and+CXF" title="Post to Delicious"><img class="nothumb" src="http://cxf.soaweb.co.in/wp-content/plugins/tweet-this/icons/tt-delicious.png" alt="Post to Delicious" /></a> <a class="tt" href="http://delicious.com/post?url=http://cxf.soaweb.co.in/index.php/2010/04/02/comparing-spring-webservices-and-cxf/&amp;title=Comparing+Spring+webservices+and+CXF" title="Post to Delicious">Delicious</a> <a class="tt" href="http://digg.com/submit?url=http://cxf.soaweb.co.in/index.php/2010/04/02/comparing-spring-webservices-and-cxf/&amp;title=Comparing+Spring+webservices+and+CXF" title="Post to Digg"><img class="nothumb" src="http://cxf.soaweb.co.in/wp-content/plugins/tweet-this/icons/tt-digg.png" alt="Post to Digg" /></a> <a class="tt" href="http://digg.com/submit?url=http://cxf.soaweb.co.in/index.php/2010/04/02/comparing-spring-webservices-and-cxf/&amp;title=Comparing+Spring+webservices+and+CXF" title="Post to Digg">Digg This Post</a></p>]]></content:encoded>
			<wfw:commentRss>http://cxf.soaweb.co.in/index.php/2010/04/02/comparing-spring-webservices-and-cxf/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Creating CXF Web Services using XSD First approach</title>
		<link>http://cxf.soaweb.co.in/index.php/2010/02/07/creating-cxf-web-services-using-xsd-first-approach/</link>
		<comments>http://cxf.soaweb.co.in/index.php/2010/02/07/creating-cxf-web-services-using-xsd-first-approach/#comments</comments>
		<pubDate>Sun, 07 Feb 2010 13:35:06 +0000</pubDate>
		<dc:creator>Naveen</dc:creator>
				<category><![CDATA[CXF Services Book]]></category>
		<category><![CDATA[Contract First Webservices]]></category>
		<category><![CDATA[CXF Contract example]]></category>
		<category><![CDATA[CXF Tutorial]]></category>
		<category><![CDATA[CXF XMLBeans]]></category>
		<category><![CDATA[XSD First Contract Web services]]></category>

		<guid isPermaLink="false">http://cxf.soaweb.co.in/?p=188</guid>
		<description><![CDATA[// 


In this blog, we will look at how to create web services using Apache CXF framework starting with XML Schema (XSD). You will probably start with XSD, when you are using contract first development and defining contract for your web services or have an existing XSD that you would want to use as part [...]]]></description>
			<content:encoded><![CDATA[<p><script type="text/javascript">// <![CDATA[
   google_ad_client = "pub-3843887054708077"; /* 468x15, created 6/2/10 */ google_ad_slot = "8275571625"; google_ad_width = 468; google_ad_height = 15;
// ]]&gt;</script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script></p>
<p>In this blog, we will look at how to create web services using Apache CXF framework starting with XML Schema (XSD). You will probably start with XSD, when you are using contract first development and defining contract for your web services or have an existing XSD that you would want to use as part of web service development.  Lot of industry schemas is available as XSD such as ACORD and while developing industry solutions for interoperability, you would typically use XSD approach if a standard schema is available for that industry domain. XSD would provide the input and output message format for web service operations.</p>
<p>We will revisit the sample example of Order process application that I had listed in my blog -  <a href="http://cxf.soaweb.co.in/index.php/2010/01/18/develop-simple-web-service-with-cxf-and-spring/" target="_blank">http://cxf.soaweb.co.in/index.php/2010/01/18/develop-simple-web-service-with-cxf-and-spring/</a> . In that blog, I had used the code first approach, where I started with Java code and exposed it as web services.</p>
<p>First we would create the contract for the Order Processing web service. We would name this as Order.xsd. Following shows the listing of Order.xsd. For simplicity, we would use the same Order.xsd schema for input and output operations.</p>
<p style="padding-left: 30px;">&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;UTF-8&#8243;?&gt;</p>
<p style="padding-left: 30px;">&lt;xs:schema attributeFormDefault=&#8221;qualified&#8221; elementFormDefault=&#8221;qualified&#8221;</p>
<p style="padding-left: 30px;">targetNamespace=&#8221;http://order.demo/&#8221; xmlns:tns=&#8221;http://order.demo/&#8221;</p>
<p style="padding-left: 30px;">xmlns:xs=&#8221;http://www.w3.org/2001/XMLSchema&#8221;&gt;</p>
<p style="padding-left: 30px;">&lt;xs:complexType name=&#8221;order&#8221;&gt;</p>
<p style="padding-left: 30px;">&lt;xs:sequence&gt;</p>
<p style="padding-left: 30px;">&lt;xs:element minOccurs=&#8221;0&#8243; type=&#8221;xs:string&#8221; /&gt;</p>
<p style="padding-left: 30px;">&lt;xs:element minOccurs=&#8221;0&#8243; type=&#8221;xs:string&#8221; /&gt;</p>
<p style="padding-left: 30px;">&lt;xs:element minOccurs=&#8221;0&#8243; type=&#8221;xs:double&#8221; /&gt;</p>
<p style="padding-left: 30px;">&lt;xs:element minOccurs=&#8221;0&#8243; type=&#8221;xs:int&#8221; /&gt;</p>
<p style="padding-left: 30px;">&lt;xs:element minOccurs=&#8221;0&#8243; type=&#8221;xs:string&#8221; /&gt;</p>
<p style="padding-left: 30px;">&lt;/xs:sequence&gt;</p>
<p style="padding-left: 30px;">&lt;/xs:complexType&gt;</p>
<p style="padding-left: 30px;">&lt;/xs:schema&gt;</p>
<p>Once you have created the contract, there are two alternatives that you have. First alternative is to  create a WSDL and include the XSD as part of it and than use the CXF WSDL2Java to create a service implementation. Next approach is to generate Java objects from XSD and used the generated object for input and output operations while creating web services. In this later approach, you don&#8217;t need to create a WSDL and instead can start off with Java code and use the generated object as input and output parameter for service methods. We would go with the second approach.</p>
<p>Next we would generate the Java type objects for XML Schema using XMLBeans . XMLBeans is a technology for accessing XML by binding it to Java types. Before that, let’s create the project structure for our web service project.  To get started, I have provided the project source code in a zip file. Download the project folder from <a class="downloadlink" href="http://cxf.soaweb.co.in/wp-content/plugins/download-monitor/download.php?id=5" title=" downloaded 90 times" >CXF XSD Source Code</a> – and unzip it any drive. You would see the following project folder .</p>
<p><img class="aligncenter size-full wp-image-197" title="cxf-xsd-first" src="http://cxf.soaweb.co.in/wp-content/uploads/2010/02/cxf-xsd-first.gif" alt="cxf-xsd-first" width="322" height="112" /></p>
<p>The schemas folder contains the Order.xsd and src contains the source code for web service project. The build.xml contained in cxfxsdfirst folder, is the ant build file for building and running the project. The build.xml requires CXF_HOME environment variable to be set to CXF distribution as it uses CXF and dependent library files from CXF_HOME\lib for building and running the code .</p>
<p>Next we would, generate the Java XML schema code for <em>Order.xsd</em> by running the following command.</p>
<p style="padding-left: 30px;">ant  buildOrderXMLBean</p>
<p>This <em>buildOrderXMLBean </em>uses the org.apache.xmlbeans.impl.tool.XMLBean class to generate Java types for Order.xsd. After running the above command, the generated compiled files would be packaged inside jar file named orderxmlbeans.jar and copied into build folder. The <em>order </em>element defined in Order.xsd would be mapped to the generated Order class. We would use the Order class as input and output parameter for the web service operation.</p>
<p>Next, we would create a service interface and service implementation for Order Process service. The service interface and implementation is exactly the same as Order Process service that was developed in code first approach in my earlier blog, hence we don’t go into much details on explaining the code. If you need more details, please refer to my earlier post- <a href="http://cxf.soaweb.co.in/index.php/2010/01/18/develop-simple-web-service-with-cxf-and-spring/" target="_blank">http://cxf.soaweb.co.in/index.php/2010/01/18/develop-simple-web-service-with-cxf-and-spring/</a></p>
<p>Following shows the service interface. The source code is available in cxfxsdfirst/src/demo/order</p>
<p style="padding-left: 30px;">package demo.order;</p>
<p style="padding-left: 30px;">import javax.jws.WebService;</p>
<p style="padding-left: 30px;">@WebService</p>
<p style="padding-left: 30px;">public interface OrderProcess {</p>
<p style="padding-left: 30px;">Order processOrder(Order order);</p>
<p style="padding-left: 30px;">}</p>
<p style="padding-left: 30px;">Note that the Order class parameter comes from the generated Java types. That’s the only difference from code first approach in terms of service interface and implementation, where we have had created the Order java bean upfront.</p>
<p>The implementation class is OrderProcessImpl.java. Following shows the listing</p>
<p style="padding-left: 30px;">package demo.order;</p>
<p style="padding-left: 30px;">
<p style="padding-left: 30px;">import javax.jws.WebService;</p>
<p style="padding-left: 30px;">@WebService</p>
<p style="padding-left: 30px;">public class OrderProcessImpl implements OrderProcess {</p>
<p style="padding-left: 30px;">public Order processOrder(Order order) {</p>
<p style="padding-left: 30px;">String orderID = validate(order);</p>
<p style="padding-left: 30px;">order.setId(orderID);</p>
<p style="padding-left: 30px;">return order;</p>
<p style="padding-left: 30px;">}</p>
<p style="padding-left: 30px;">//Rest of the code commented out. Refer to downloaded code</p>
<p style="padding-left: 30px;">}</p>
<p>Next, we would create a Stand-alone server named Server.java that would publish the order process server.  The following shows the code listing. The code is available in cxfxsdfirst/src/demo/order.</p>
<p style="padding-left: 30px;">package demo.order;</p>
<p style="padding-left: 30px;">import java.io.BufferedReader;</p>
<p style="padding-left: 30px;">import java.io.IOException;</p>
<p style="padding-left: 30px;">import java.io.InputStreamReader;</p>
<p style="padding-left: 30px;">
<p style="padding-left: 30px;">import org.apache.cxf.databinding.DataBinding;</p>
<p style="padding-left: 30px;">import org.apache.cxf.jaxws.JaxWsServerFactoryBean;</p>
<p style="padding-left: 30px;">
<p style="padding-left: 30px;">public class Server {</p>
<p style="padding-left: 30px;">public static void main(String[] args) {</p>
<p style="padding-left: 30px;">// Service instance</p>
<p style="padding-left: 30px;">OrderProcess orderProcess = new OrderProcessImpl();</p>
<p style="padding-left: 30px;">//AddressVerifyProcess orderProcess = new AddressVerifyProcessImpl();</p>
<p style="padding-left: 30px;">JaxWsServerFactoryBean restServer = new JaxWsServerFactoryBean();</p>
<p style="padding-left: 30px;">restServer.setServiceBean(orderProcess);</p>
<p style="padding-left: 30px;">restServer.setAddress(&#8221;http://localhost:8080/&#8221;);</p>
<p style="padding-left: 30px;">try {</p>
<p style="padding-left: 30px;">restServer.setDataBinding(org.apache.cxf.xmlbeans.XmlBeansDataBinding.class.newInstance());</p>
<p style="padding-left: 30px;">} catch (IllegalAccessException e1) {</p>
<p style="padding-left: 30px;">e1.printStackTrace();</p>
<p style="padding-left: 30px;">} catch (InstantiationException e1) {</p>
<p style="padding-left: 30px;">e1.printStackTrace();</p>
<p style="padding-left: 30px;">}</p>
<p style="padding-left: 30px;">restServer.create();</p>
<p style="padding-left: 30px;">BufferedReader br = new BufferedReader(new InputStreamReader(System.in));</p>
<p style="padding-left: 30px;">try {</p>
<p style="padding-left: 30px;">br.readLine();</p>
<p style="padding-left: 30px;">} catch (IOException e) {</p>
<p style="padding-left: 30px;">}</p>
<p style="padding-left: 30px;">System.out.println(&#8221;Server Stopped&#8221;);</p>
<p style="padding-left: 30px;">}</p>
<p style="padding-left: 30px;">}</p>
<p style="padding-left: 30px;">
<p>The code above uses the JaxWsServerFactoryBean for publishing the Order Process service class over address <a href="http://localhost:8080/">http://localhost:8080/</a>. The most important code of the Order Process is the following line –</p>
<p style="padding-left: 30px;">restServer.setDataBinding(org.apache.cxf.xmlbeans.XmlBeansDataBinding.class.newInstance());</p>
<p>This tells the CFX framework to uses XmlBeans data binding , instead of default JAXB data binding.</p>
<p>Next , we would create a stand-alone client that would invoke the Order Process service. The client and Spring configuration file s similar to one developed for code first. If you need details of the explanation of the code. please refer to Developing a client section in <a href="http://cxf.soaweb.co.in/index.php/2010/01/18/develop-simple-web-service-with-cxf-and-spring/" target="_blank">http://cxf.soaweb.co.in/index.php/2010/01/18/develop-simple-web-service-with-cxf-and-spring/</a> blog.</p>
<p>The client code is available in &#8211; cxfxsdfirst/src/demo/order/client folder. Following shows the code listing for Client.java</p>
<p style="padding-left: 30px;">package demo.order.client;</p>
<p style="padding-left: 30px;">import demo.order.OrderProcess;</p>
<p style="padding-left: 30px;">import demo.order.Order;</p>
<p style="padding-left: 30px;">import demo.order.impl.OrderImpl;</p>
<p style="padding-left: 30px;">import org.springframework.context.support.ClassPathXmlApplicationContext;</p>
<p style="padding-left: 30px;">public final class Client {</p>
<p style="padding-left: 30px;">public Client() {</p>
<p style="padding-left: 30px;">}</p>
<p style="padding-left: 30px;">public static void main(String args[]) throws Exception {</p>
<p style="padding-left: 30px;">ClassPathXmlApplicationContext context</p>
<p style="padding-left: 30px;">= new ClassPathXmlApplicationContext(new String[] {&#8221;demo/order/client/client-beans.xml&#8221;});</p>
<p style="padding-left: 30px;">OrderProcess client = (OrderProcess) context.getBean(&#8221;orderClient&#8221;);</p>
<p style="padding-left: 30px;">Order order = Order.Factory.newInstance();</p>
<p style="padding-left: 30px;">order.setCustomerID(&#8221;C001&#8243;);</p>
<p style="padding-left: 30px;">order.setItemID(&#8221;I001&#8243;);</p>
<p style="padding-left: 30px;">order.setQty(100);</p>
<p style="padding-left: 30px;">order.setPrice(200.00);</p>
<p style="padding-left: 30px;">Order orderResponse = client.processOrder(order);</p>
<p style="padding-left: 30px;">String message = (orderResponse.getId() == null) ? &#8220;Order not approved&#8221; : &#8220;Order approved; order ID is &#8221; + orderResponse.getId();</p>
<p style="padding-left: 30px;">System.out.println(message);</p>
<p style="padding-left: 30px;">}</p>
<p style="padding-left: 30px;">}</p>
<p style="padding-left: 30px;">The following shows the “client-beans.xml”, the Spring configuration file which is used by Client.java.</p>
<p style="padding-left: 30px;">&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;UTF-8&#8243;?&gt;</p>
<p style="padding-left: 30px;">&lt;beans xmlns=&#8221;http://www.springframework.org/schema/beans&#8221;</p>
<p style="padding-left: 30px;">xmlns:xsi=&#8221;http://www.w3.org/2001/XMLSchema-instance&#8221;</p>
<p style="padding-left: 30px;">xmlns:jaxws=&#8221;http://cxf.apache.org/jaxws&#8221;</p>
<p style="padding-left: 30px;">xsi:schemaLocation=&#8221;</p>
<p style="padding-left: 30px;">http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd</p>
<p style="padding-left: 30px;">http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd&#8221;&gt;</p>
<p style="padding-left: 30px;">
<p style="padding-left: 30px;">&lt;jaxws:client id=&#8221;orderClient&#8221; serviceClass=&#8221;demo.order.OrderProcess&#8221; address=&#8221;http://localhost:8080/orderapp/OrderProcess&#8221; &gt;</p>
<p style="padding-left: 30px;">&lt;jaxws:dataBinding&gt;</p>
<p style="padding-left: 30px;">&lt;bean class=&#8221;org.apache.cxf.xmlbeans.XmlBeansDataBinding&#8221;/&gt;</p>
<p style="padding-left: 30px;">&lt;/jaxws:dataBinding&gt;</p>
<p style="padding-left: 30px;">&lt;/jaxws:client&gt;</p>
<p style="padding-left: 30px;">&lt;/beans&gt;</p>
<p>The following definition tells the CXF framework to use XMLBeans data binding framework.</p>
<p style="padding-left: 30px;">&lt;jaxws:dataBinding&gt;</p>
<p style="padding-left: 30px;">&lt;bean class=&#8221;org.apache.cxf.xmlbeans.XmlBeansDataBinding&#8221;/&gt;</p>
<p style="padding-left: 30px;">&lt;/jaxws:dataBinding&gt;</p>
<p>Next, we would see our code in action.  The outline is same as one defined in  Running the code section of my earlier blog – <a href="../index.php/2010/01/18/develop-simple-web-service-with-cxf-and-spring/" target="_blank">http://cxf.soaweb.co.in/index.php/2010/01/18/develop-simple-web-service-with-cxf-and-spring/</a></p>
<p>Navigate to cxfxsdfirst and type in the following command</p>
<ul>
<li>ant build</li>
</ul>
<p style="padding-left: 30px;">This would build the source code.</p>
<ul>
<li>ant server</li>
</ul>
<p style="padding-left: 30px;">This would execute the Java class &#8211; demo.order.Server and publish the OrderProcess service over address <a href="http://localhost:8080/">http://localhost:8080</a> .     You can see the WSDL for OrderProcess service by typing the URL &#8211; <a href="http://localhost:8080/OrderProcess?wsdl">http://localhost:8080/OrderProcess?wsdl</a> in the browser</p>
<ul>
<li>ant client</li>
</ul>
<p style="padding-left: 30px;">Open up a new window and type the above command. The would execute the Java class &#8211; demo.order.client.Client and invoke the OrderProcess service. You would see the order id being displayed in the console.</p>
<p><script type="text/javascript">// <![CDATA[
   google_ad_client = "pub-3843887054708077"; /* 468x15, created 6/2/10 */ google_ad_slot = "8275571625"; google_ad_width = 468; google_ad_height = 15;
// ]]&gt;</script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script></p>
<p>To know, more about how to develop SOAP and RESTful web services, get a copy of the Apache CXF Web Service Book -<a href="http://www.packtpub.com/apache-cxf-web-service-development/mid/2312092oq0d7?utm_source=cxf.soaweb.co.in&amp;utm_medium=affiliate&amp;utm_content=authorsite&amp;utm_campaign=mdb_001927" target="_blank"><div class="amzshcs" id="amzshcs-0ffe1990b5c22a8e10d5ec748e774099"><div class="amzshcs-item" id="amzshcs-item-b8543e78f0aeb0dd818a17e03e0b28ed"> <a href="http://www.amazon.com/Apache-CXF-Web-Service-Development/dp/1847195407%3FSubscriptionId%3DAKIAJWQLRXGXNE5KBGJA%26tag%3Dsw0fd-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D1847195407"><img src="http://ecx.images-amazon.com/images/I/51Sstnuk-CL._SL160_.jpg" height="160" width="130" alt="Image of Apache CXF Web Service Development" title="Apache CXF Web Service Development" /></a> </div></div> </a></p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Creating+CXF+Web+Services+using+XSD+First+approach+http://cxf.soaweb.co.in/?p=188" title="Post to Twitter"><img class="nothumb" src="http://cxf.soaweb.co.in/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Creating+CXF+Web+Services+using+XSD+First+approach+http://cxf.soaweb.co.in/?p=188" title="Post to Twitter">Tweet This Post</a> <a class="tt" href="http://delicious.com/post?url=http://cxf.soaweb.co.in/index.php/2010/02/07/creating-cxf-web-services-using-xsd-first-approach/&amp;title=Creating+CXF+Web+Services+using+XSD+First+approach" title="Post to Delicious"><img class="nothumb" src="http://cxf.soaweb.co.in/wp-content/plugins/tweet-this/icons/tt-delicious.png" alt="Post to Delicious" /></a> <a class="tt" href="http://delicious.com/post?url=http://cxf.soaweb.co.in/index.php/2010/02/07/creating-cxf-web-services-using-xsd-first-approach/&amp;title=Creating+CXF+Web+Services+using+XSD+First+approach" title="Post to Delicious">Delicious</a> <a class="tt" href="http://digg.com/submit?url=http://cxf.soaweb.co.in/index.php/2010/02/07/creating-cxf-web-services-using-xsd-first-approach/&amp;title=Creating+CXF+Web+Services+using+XSD+First+approach" title="Post to Digg"><img class="nothumb" src="http://cxf.soaweb.co.in/wp-content/plugins/tweet-this/icons/tt-digg.png" alt="Post to Digg" /></a> <a class="tt" href="http://digg.com/submit?url=http://cxf.soaweb.co.in/index.php/2010/02/07/creating-cxf-web-services-using-xsd-first-approach/&amp;title=Creating+CXF+Web+Services+using+XSD+First+approach" title="Post to Digg">Digg This Post</a></p>]]></content:encoded>
			<wfw:commentRss>http://cxf.soaweb.co.in/index.php/2010/02/07/creating-cxf-web-services-using-xsd-first-approach/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Deploying Apache CXF application on WebSphere Process Server</title>
		<link>http://cxf.soaweb.co.in/index.php/2010/01/24/deploying-apache-cxf-application-on-websphere-process-server/</link>
		<comments>http://cxf.soaweb.co.in/index.php/2010/01/24/deploying-apache-cxf-application-on-websphere-process-server/#comments</comments>
		<pubDate>Sun, 24 Jan 2010 06:02:56 +0000</pubDate>
		<dc:creator>Naveen</dc:creator>
				<category><![CDATA[CXF Services Book]]></category>
		<category><![CDATA[cxf depolyment]]></category>
		<category><![CDATA[CXF WAS WPS]]></category>

		<guid isPermaLink="false">http://cxf.soaweb.co.in/?p=158</guid>
		<description><![CDATA[  Amazon.com Widgets
In this blog, we we look at how to deploy CXF application on WebSphere Process Server (WPS). One of the readers had asked  me on how to deploy the sample application from Chapter 2  in WPS, since the book covers deployment on tomcat server only. It was a good exercise for [...]]]></description>
			<content:encoded><![CDATA[<p><SCRIPT charset="utf-8" type="text/javascript" src="http://ws.amazon.com/widgets/q?ServiceVersion=20070822&#038;MarketPlace=US&#038;ID=V20070822/US/sw0fd-20/8002/a6600341-d69b-4eaa-b2da-c1f69679d327"> </SCRIPT> <NOSCRIPT><A HREF="http://ws.amazon.com/widgets/q?ServiceVersion=20070822&#038;MarketPlace=US&#038;ID=V20070822%2FUS%2Fsw0fd-20%2F8002%2Fa6600341-d69b-4eaa-b2da-c1f69679d327&#038;Operation=NoScript">Amazon.com Widgets</A></NOSCRIPT></p>
<p>In this blog, we we look at how to deploy CXF application on WebSphere Process Server (WPS). One of the readers had asked  me on how to deploy the sample application from Chapter 2 (<a class="downloadlink" href="http://cxf.soaweb.co.in/wp-content/plugins/download-monitor/download.php?id=2" title="Version 1.0 downloaded 291 times" >Sample Apache CXF Web Service Book Chapter</a>) in WPS, since the book covers deployment on tomcat server only. It was a good exercise for me to validate  if the sample CXF application run on other servers as I haven&#8217;t tried this before. <span id="more-158"></span>I was able to run the application successfully with a modification to the module class loading policy . Given below are the steps required to deploy the sample CXF application (orderapp) in WPS. The version of WPS used was 7.0.</p>
<ol>
<li>Build the war file (orderapp.war) as  mentioned in Chapter 2.</li>
<li>Logon to WPS Administration Console</li>
<li>Go to <em>Applications -&gt; Application Types &#8211; &gt; WebSphere Enterprise applications</em>. Click Install</li>
<li>In next screen , provide the location of orderapp.war file.Click <em>Next</em></li>
<li>On the next screen, click <em>Fast Path</em> and click on <em>Next</em></li>
<li>On the <em>Install New Application</em> screen, Click on <em>Step 3 Map virtual hosts for Web modules</em> and select the orderapp.war file to map it to default_host virtual host</li>
<li>On the <em>Install New Application</em> screen, Click on<em> Step 4 Map context root for Web modules </em>and enter  the context root as /orderapp as shown below. Click <em>Next<img class="aligncenter size-full wp-image-160" title="specify-cxf-context-root" src="http://cxf.soaweb.co.in/wp-content/uploads/2010/01/specify-context-root.gif" alt="specify-cxf-context-root" width="588" height="311" /></em></li>
<li>On the Summary screen, click Finish.</li>
<li>The orderapp.war would be deployed. On the confirmation screen, click <em>Save </em>to save the configuration to master configuration.</li>
</ol>
<p>Next,  you need to change the class loading policy for orderapp web module, to ensure that the CXF libraries, CXF JAX-WS and JAX-RS runtime and dependent files present in web module (all jar files in WEB-INF\lib) are loaded first , instead of WPS library to avoid any conflict. If  you don&#8217;t change the class loading policy , the application deployment would be successful but would receive the following exception when you run the application -</p>
<p style="padding-left: 30px;">com.ibm.ws.webcontainer.servlet.ServletWrapper service SRVE0068E: Uncaught exception created in one of the service methods of the servlet CXFServlet in application orderapp_war. Exception created : java.lang.NoSuchMethodError: org/apache/ws/commons/schema/XmlSchema.getSchemaDocument()Lorg/w3c/dom/Document;<br />
at org.apache.cxf.service.model.SchemaInfo.getElement(SchemaInfo.java:109)<br />
at org.apache.cxf.wsdl11.ServiceWSDLBuilder.buildTypes(ServiceWSDLBuilder.java:267)<br />
at org.apache.cxf.wsdl11.ServiceWSDLBuilder.build(ServiceWSDLBuilder.java:188)<br />
at org.apache.cxf.wsdl11.ServiceWSDLBuilder.build(ServiceWSDLBuilder.java:148)</p>
<p><script type="text/javascript">// <![CDATA[
   google_ad_client = "pub-3843887054708077"; /* 468x15, created 6/2/10 */ google_ad_slot = "8275571625"; google_ad_width = 468; google_ad_height = 15;
// ]]&gt;</script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script></p>
<p>To change the class loading policy , follow these steps</p>
<ol>
<li>Go to <em>Applications </em>-&gt; <em>Application </em>Types &#8211; &gt; <em>WebSphere enterprise applications</em> and select <em>orderapp_war</em></li>
<li>Click on <em>Manage modules</em></li>
<li>Click on <em>orderapp.war</em></li>
<li>Change the class loader order to &#8220;<em>Classes loaded with local class loader first (parent last)</em>&#8221; as shown belo and click <em>Apply</em>. <em>Save </em>the configuration.<img class="aligncenter size-full wp-image-161" title="changing-cxf-class-loader" src="http://cxf.soaweb.co.in/wp-content/uploads/2010/01/changing-class-loader.gif" alt="changing-cxf-class-loader" width="678" height="407" /></li>
<li>Start the <em>orderapp_war enterprise application</em></li>
<li>Run the web service client as mentioned in Chapter 2</li>
</ol>
<p>Note if you plan to use CXF JAX-WS implementation with WAS/WPS , you would not be able to leverage the WS-Specifications (like WS-Security) offered by WAS/WPS container for that application and instead need to rely on CXF WS-Specification implementation.</p>
<p>To know, more about how to develop SOAP and RESTful web services, get a copy of the Apache CXF Web Service Book <a href="http://www.packtpub.com/apache-cxf-web-service-development/mid/2312092oq0d7?utm_source=cxf.soaweb.co.in&amp;utm_medium=affiliate&amp;utm_content=authorsite&amp;utm_campaign=mdb_001927" target="_blank"><div class="amzshcs" id="amzshcs-0ffe1990b5c22a8e10d5ec748e774099"><div class="amzshcs-item" id="amzshcs-item-b8543e78f0aeb0dd818a17e03e0b28ed"> <a href="http://www.amazon.com/Apache-CXF-Web-Service-Development/dp/1847195407%3FSubscriptionId%3DAKIAJWQLRXGXNE5KBGJA%26tag%3Dsw0fd-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D1847195407"><img src="http://ecx.images-amazon.com/images/I/51Sstnuk-CL._SL160_.jpg" height="160" width="130" alt="Image of Apache CXF Web Service Development" title="Apache CXF Web Service Development" /></a> </div></div> </a></p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Deploying+Apache+CXF+application+on+WebSphere+Process+Server+http://cxf.soaweb.co.in/?p=158" title="Post to Twitter"><img class="nothumb" src="http://cxf.soaweb.co.in/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Deploying+Apache+CXF+application+on+WebSphere+Process+Server+http://cxf.soaweb.co.in/?p=158" title="Post to Twitter">Tweet This Post</a> <a class="tt" href="http://delicious.com/post?url=http://cxf.soaweb.co.in/index.php/2010/01/24/deploying-apache-cxf-application-on-websphere-process-server/&amp;title=Deploying+Apache+CXF+application+on+WebSphere+Process+Server" title="Post to Delicious"><img class="nothumb" src="http://cxf.soaweb.co.in/wp-content/plugins/tweet-this/icons/tt-delicious.png" alt="Post to Delicious" /></a> <a class="tt" href="http://delicious.com/post?url=http://cxf.soaweb.co.in/index.php/2010/01/24/deploying-apache-cxf-application-on-websphere-process-server/&amp;title=Deploying+Apache+CXF+application+on+WebSphere+Process+Server" title="Post to Delicious">Delicious</a> <a class="tt" href="http://digg.com/submit?url=http://cxf.soaweb.co.in/index.php/2010/01/24/deploying-apache-cxf-application-on-websphere-process-server/&amp;title=Deploying+Apache+CXF+application+on+WebSphere+Process+Server" title="Post to Digg"><img class="nothumb" src="http://cxf.soaweb.co.in/wp-content/plugins/tweet-this/icons/tt-digg.png" alt="Post to Digg" /></a> <a class="tt" href="http://digg.com/submit?url=http://cxf.soaweb.co.in/index.php/2010/01/24/deploying-apache-cxf-application-on-websphere-process-server/&amp;title=Deploying+Apache+CXF+application+on+WebSphere+Process+Server" title="Post to Digg">Digg This Post</a></p>]]></content:encoded>
			<wfw:commentRss>http://cxf.soaweb.co.in/index.php/2010/01/24/deploying-apache-cxf-application-on-websphere-process-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apache CXF web service framework architecture overview</title>
		<link>http://cxf.soaweb.co.in/index.php/2010/01/23/apache-cxf-webservice-framework-architecture-overview/</link>
		<comments>http://cxf.soaweb.co.in/index.php/2010/01/23/apache-cxf-webservice-framework-architecture-overview/#comments</comments>
		<pubDate>Sat, 23 Jan 2010 06:54:28 +0000</pubDate>
		<dc:creator>Naveen</dc:creator>
				<category><![CDATA[CXF Services Book]]></category>
		<category><![CDATA[apache cxf]]></category>
		<category><![CDATA[apache cxf book]]></category>
		<category><![CDATA[cxf architecture]]></category>

		<guid isPermaLink="false">http://cxf.soaweb.co.in/?p=146</guid>
		<description><![CDATA[// 


In this blog, we would provide an overview of CXF Architecture. The architecture of CXF is built upon the following components:
• Bus
• Frontend
• Messaging and Interceptors
• Service Model
• Data bindings
• Protocol bindings
• Transport
The following figure shows the overall architecture:

Bus 
Bus is the backbone of the CXF architecture. The CXF bus is comprised of a [...]]]></description>
			<content:encoded><![CDATA[<p><script type="text/javascript">// <![CDATA[
   google_ad_client = "pub-3843887054708077"; /* 468x15, created 6/2/10 */ google_ad_slot = "8275571625"; google_ad_width = 468; google_ad_height = 15;
// ]]&gt;</script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script></p>
<p>In this blog, we would provide an overview of CXF Architecture. The architecture of CXF is built upon the following components:</p>
<p>• Bus</p>
<p>• Frontend</p>
<p>• Messaging and Interceptors</p>
<p>• Service Model</p>
<p>• Data bindings</p>
<p>• Protocol bindings</p>
<p>• Transport</p>
<p>The following figure shows the overall architecture:</p>
<p><img class="aligncenter size-full wp-image-149" title="cxf-archiecture" src="http://cxf.soaweb.co.in/wp-content/uploads/2010/01/cxf-archiecture.jpg" alt="cxf-archiecture" width="403" height="250" /></p>
<p><strong>Bus </strong></p>
<p><strong>Bus </strong>is the backbone of the CXF architecture. The CXF bus is comprised of a Spring-based configuration file, namely, cxf.xml which is loaded upon servlet initialization through SpringBusFactory. It defines a common context for all the endpoints. It wires all the runtime infrastructure components and provides a common application context. The SpringBusFactory scans and loads the relevant configuration files in the META-INF/cxf directory placed in the classpath and accordingly builds the application context. It builds the application context from the following files:</p>
<p>• META-INF/cxf/cxf.xml</p>
<p>• META-INF/cxf/cxf-extension.xml</p>
<p>• META-INF/cxf/cxf-property-editors.xml</p>
<p>The XML file is part of the installation bundle&#8217;s core CXF library JAR. Now, we know that CXF internally uses Spring for its configuration. The following XML fragment shows the bus definition in the cxf.xml file.</p>
<p style="padding-left: 30px;">&lt;bean class=&#8221;org.apache.cxf.bus.CXFBusImpl&#8221; /&gt;</p>
<p>The core bus component is CXFBusImpl. The class acts more as an interceptor provider for incoming and outgoing requests to a web service endpoint. These interceptors, once defined, are available to all the endpoints in that context. The cxf.xml file also defines other infrastructure components such as BindingFactoryManager, ConduitFactoryManager, and so on. These components are made available as bus extensions. One can access these infrastructure objects using the getExtension method. These infrastructure components are registered so as to get and update various service endpoint level parameters such as service binding, transport protocol, conduits, and so on.</p>
<p>CXF bus architecture can be overridden, but one must apply caution when overriding the default bus behavior. Since the bus is the core component that loads the CXF runtime, many shared objects are also loaded as part of this runtime. You want to make sure that these objects are loaded when overriding the existing bus implementation.</p>
<p>You can extend the default bus to include your own custom components or service objects such as factory managers. You can also add interceptors to the bus bean. These interceptors defined at the bus level are available to all the endpoints. The following code shows how to create a custom bus:</p>
<p style="padding-left: 30px;">SpringBeanFactory.createBus(&#8221;mycxf.xml&#8221;)</p>
<p>SpringBeanFactory class is used to create a bus. You can complement or overwrite the bean definitions that the original cxf.xml file would use. For the CXF to load the mycxf.xml file, it has to be in the classpath or you can use a factory method to load the file. The following code illustrates the use of interceptors at the bus level:</p>
<p style="padding-left: 30px;">&lt;bean class=&#8221;org.apache.cxf.bus.spring.SpringBusImpl&#8221;&gt;</p>
<p style="padding-left: 30px;">&lt;property name=&#8221;outInterceptors&#8221;&gt;</p>
<p style="padding-left: 30px;">&lt;list&gt;</p>
<p style="padding-left: 30px;">&lt;ref bean=&#8221;myLoggingInterceptor&#8221;/&gt;</p>
<p style="padding-left: 30px;">&lt;/list&gt;</p>
<p style="padding-left: 30px;">&lt;/property&gt;</p>
<p style="padding-left: 30px;">&lt;/bean&gt;</p>
<p style="padding-left: 30px;">&lt;bean class=&#8221;org.mycompany.com.cxf.logging. LoggingInterceptor&#8221;&gt;</p>
<p style="padding-left: 30px;">&#8230;</p>
<p style="padding-left: 30px;">&lt;/bean&gt;</p>
<p>The preceding bus definition adds the logging interceptor that will perform logging for all outgoing messages.</p>
<p><strong>Frontend </strong></p>
<p>CXF provides the concept of frontend modeling, which lets you create web services using different frontend APIs. The APIs let you create a web service using simple factory beans and JAX-WS implementation. It also lets you create dynamic web service clients. The primary frontend supported by CXF is JAX-WS. We will look at how to use the Frontend programming model in the next chapter.</p>
<p><strong>JAX</strong><strong>-WS </strong></p>
<p>JAX-WS is a specification that establishes the semantics to develop, publish, and consume web services. JAX-WS simplifies web service development. JAX-WS defines Java-based APIs that ease the development and deployment of web services. The specification supports WS-Basic Profile 1.1 that addresses web service interoperability. It effectively means a web service can be invoked or consumed by a client written in any language. JAX-WS also defines standards such as <strong>JAXB</strong><strong> </strong>and <strong>SAAJ</strong>. CXF provides support for complete JAX-WS stack.</p>
<p>JAXB provides data binding capabilities by providing a convenient way to map XML schema to a representation in Java code. The JAXB shields the conversion of XML schema messages in SOAP messages to Java code without the developers seeing XML and SOAP parsing. JAXB specification defines the binding between Java and XML Schema. SAAJ provides a standard way of dealing with XML attachments contained in a SOAP message.</p>
<p>JAX-WS also speeds up web service development by providing a library of annotations to turn Plain Old Java classes into web services and specifies a detailed mapping from a service defined in WSDL to the Java classes that will implement that service. Any complex types defined in WSDL are mapped into Java classes following the mapping defined by the JAXB specification.</p>
<p>As discussed earlier, two approaches for web service development exist: Code-First and Contract-First. With JAX-WS, you can perform web service development using one of the said approaches, depending on the nature of the application.</p>
<p>With the Code-first approach, you start by developing a Java class and interface and annotating the same as a web service. The approach is particularly useful where Java implementations are already available and you need to expose implementations as services.</p>
<p>You typically create a <strong>Service Endpoint Interface </strong>(<strong>SEI</strong>) that defines the service methods and the implementation class that implements the SEI methods. The consumer of a web service uses SEI to invoke the service functions. The SEI directly corresponds to a wsdl:portType element. The methods defined by SEI correspond to the wsdl:operation element.</p>
<p style="padding-left: 30px;">@WebService</p>
<p style="padding-left: 30px;">public interface OrderProcess {</p>
<p style="padding-left: 30px;">String processOrder(Order order);</p>
<p style="padding-left: 30px;">}</p>
<p style="padding-left: 30px;">
<p>JAX-WS makes use of annotations to convert an SEI or a Java class to a web service. In the above example, the @WebService annotation defined above the interface declaration signifies an interface as a web service interface or Service Endpoint Interface. In the Contract-first approach, you start with the existing WSDL contract, and generate Java class to implement the service. The advantage is that you are sure about what to expose as a service since you define the appropriate WSDL Contract-first. Again the contract definitions can be made consistent with respect to data types so that it can be easily converted in Java objects without any portability issue.</p>
<p>WSDL contains different elements that can be directly mapped to a Java class that implements the service. For example, the wsdl:portType element is directly mapped to SEI, type elements are mapped to Java class types through the use of Java Architecture of XML Binding (JAXB), and the wsdl:service element is mapped to a Java class that is used by a consumer to access the web service.</p>
<p>The WSDL2Java tool can be used to generate a web service from WSDL. It has various options to generate SEI and the implementation web service class. As a developer, you need to provide the method implementation for the generated class. If the WSDL includes custom XML Schema types, then the same is converted into its equivalent Java class.</p>
<p><strong>Simple frontend </strong></p>
<p>Apart from JAX-WS frontend, CXF also supports what is known as &#8217;simple frontend&#8217;. The simple frontend provides simple components or Java classes that use reflection to build and publish web services. It is simple because we do not use any annotation to create web services. In JAX-WS, we have to annotate a Java class to denote it as a web service and use tools to convert between a Java object and WSDL. The simple frontend uses factory components to create a service and the client. It does so by using Java reflection API. In Chapter 3 we will look at how to develop simple frontend web services</p>
<p>The following code shows a web service created using simple frontend:</p>
<p style="padding-left: 30px;">// Build and publish the service</p>
<p style="padding-left: 30px;">OrderProcessImpl orderProcessImpl = new OrderProcessImpl();</p>
<p style="padding-left: 30px;">ServerFactoryBean svrFactory = new ServerFactoryBean();</p>
<p style="padding-left: 30px;">svrFactory.setServiceClass(OrderProcess.class);</p>
<p style="padding-left: 30px;">svrFactory.setAddress(&#8221;http://localhost:8080/OrderProcess&#8221;);</p>
<p style="padding-left: 30px;">svrFactory.setServiceBean(orderProcessImpl);</p>
<p style="padding-left: 30px;">svrFactory.create();</p>
<p style="padding-left: 30px;"><strong><br />
</strong></p>
<p><strong>Messaging and Interceptors </strong></p>
<p><strong> </strong>One of the important elements of CXF architecture is the Interceptor components. Interceptors are components that intercept the messages exchanged or passed between web service clients and server components. In CXF, this is implemented through the concept of Interceptor chains. The concept of Interceptor chaining is the core functionality of CXF runtime.</p>
<p>The interceptors act on the messages which are sent and received from the web service and are processed in chains. Each interceptor in a chain is configurable, and the user has the ability to control its execution.</p>
<p><img class="aligncenter size-full wp-image-150" title="cxf-interceptor-chain" src="http://cxf.soaweb.co.in/wp-content/uploads/2010/01/cxf-interceptor-chain.jpg" alt="cxf-interceptor-chain" width="331" height="257" /></p>
<p>The core of the framework is the Interceptor interface. It defines two abstract methods—handleMessage and handleFault. Each of the methods takes the object of type Message as a parameter. A developer implements the handleMessage to process or act upon the message. The handleFault method is implemented to handle the error condition. Interceptors are usually processed in chains, with every interceptor in the chain performing some processing on the message in sequence, and the chain moves forward. Whenever an error condition arises, a handleFault method is invoked on each interceptor, and the chain unwinds or moves backwards.</p>
<p>Interceptors are often organized or grouped into phases. Interceptors providing common functionality can be grouped into one phase. Each phase performs specific message processing. Each phase is then added to the interceptor chain. The chain, therefore, is a list of ordered interceptor phases. The chain can be created for both inbound and outbound messages. A typical web service endpoint will have three interceptor chains:</p>
<p>• Inbound messages chain</p>
<p>• Outbound messages chain</p>
<p>• Error messages chain</p>
<p>There are built-in interceptors such as logging, security, and so on, and the developers can also choose to create custom interceptors.</p>
<p><strong>Service model </strong></p>
<p>The Service model, in a true sense, models your service. The Service model is a framework of components that represents a service in a WSDL-like model. It provides functionality to create various WSDL elements such as operations, bindings, endpoints, schema, and so on. The following figure shows the various components that form the Service model:</p>
<p><img class="aligncenter size-full wp-image-151" title="cxf-service-model" src="http://cxf.soaweb.co.in/wp-content/uploads/2010/01/cxf-service-model.jpg" alt="cxf-service-model" width="247" height="178" /></p>
<p align="center">
<p>The components of the Service model can be used to create a service. As you can see from the above figure, the service model&#8217;s primary component is ServiceInfo which aggregates other related components that make up the complete service model. <strong>ServiceInfo </strong>is comprised of the following components that more or less represent WSDL elements:</p>
<p>• <strong>InterfaceInfo </strong></p>
<p>• <strong>OperationInfo </strong></p>
<p>• <strong>MessageInfo </strong></p>
<p>• <strong>BindingInfo </strong></p>
<p>• <strong>EndpointInfo </strong></p>
<p>A web service is usually created using one of the frontends offered by CXF. It can be either constructed from a Java class or from a WSDL. CXF frontends internally use the service model to create web services. For example, by using a simple frontend, we can create, publish, and consume web services through factory components such as ServerFactoryBean and ClientProxyFactoryBean. These factory classes internally use the service model of CXF.</p>
<p><strong>Data binding </strong></p>
<p>Data binding is the key for any web service development. Data binding means mapping between Java objects and XML elements. As we know, with web service, messages are exchanged as XML artifacts. So there has to be some way to convert these XML into Java objects and vice versa for the application to process as service and client. Data binding components perform this mapping for you. CXF supports two types of data binding components—<strong>JAXB</strong><strong> </strong>and <strong>Aegis</strong>. CXF uses JAXB as the default data binding component. As a developer, you have the choice of specifying the binding discipline through a configuration file or API. If no binding is specified, then JAXB is taken as a default binding discipline. The latest version of CXF uses JAXB 2.1. JAXB uses annotations to define the mapping between Java objects and XML. The following code illustrates the use of JAXB annotations:</p>
<p style="padding-left: 30px;">@XmlRootElement(name=&#8221;processOrder&#8221;, namespace=&#8221; http://localhost/ orderprocess&#8221;)</p>
<p style="padding-left: 30px;">@XmlAccessorType(XmlAccessType.FIELD)</p>
<p style="padding-left: 30px;">@XmlType(name=&#8221;processOrder&#8221;, namespace= &#8221; http://localhost/orderprocess&#8221;)</p>
<p style="padding-left: 30px;">public class OrderProcess {</p>
<p style="padding-left: 30px;">@XmlElement(name=&#8221;arg0&#8243;, namespace=&#8221;")</p>
<p style="padding-left: 30px;">private order.Order arg0;</p>
<p style="padding-left: 30px;">//Gettter and Setter</p>
<p style="padding-left: 30px;">….</p>
<p style="padding-left: 30px;">}</p>
<p>As shown in the previous code, the @Xml specific annotations represents the JAXB metadata that is used by JAXB to map Java classes to XML schema constructs. For example, the @XmlType annotation specifies that the OrderProcess class will be mapped to complex XSD element type &#8216;processOrder&#8217; that contains an element &#8216;arg0&#8242; of type &#8216;Order&#8217; bean.</p>
<p>CXF also supports the Aegis data binding component to map between Java objects and XML. Aegis allows developers to gain control of data binding through its flexible mapping system. You do not have to rely on annotations to devise the mapping. Your Java code is clean and simple POJO.</p>
<p>Aegis also supports some annotations that can be used to devise binding. Some of the annotations that can be used with Aegis are:</p>
<p>• XmlAttribute</p>
<p>• XmlElement</p>
<p>• XmlParamType</p>
<p>• XmlReturnType</p>
<p>• XmlType</p>
<p>In Aegis, you define the data mapping in a file called &lt;MyJavaObject&gt;.aegis.xml, where MyJavaObject is the object that you are trying to map with XML. Aegis reads this XML to perform the necessary binding. Aegis also uses reflection to derive the mapping between Java object and XML. The following code fragment shows the sample Aegis mapping file:</p>
<p style="padding-left: 30px;">&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;UTF-8&#8243;?&gt;</p>
<p style="padding-left: 30px;">&lt;mappings&gt;</p>
<p style="padding-left: 30px;">&lt;mapping name=&#8221;HelloWorld&#8221;&gt;</p>
<p style="padding-left: 30px;">&lt;method name=&#8221;sayHi&#8221;&gt;</p>
<p style="padding-left: 30px;">&lt;parameter index=&#8221;0&#8243; mappedName= &#8220;greeting&#8221; nillable=&#8217;false&#8217; /&gt;</p>
<p style="padding-left: 30px;">&lt;/method&gt;</p>
<p style="padding-left: 30px;">&lt;/mapping&gt;</p>
<p style="padding-left: 30px;">&lt;/mappings&gt;</p>
<p>The above XML fragment states that a string parameter of a method named sayHi of the bean HelloWorld should be mapped to a name as greeting.</p>
<p>You can configure your web service to use Aegis data binding as follows:</p>
<p style="padding-left: 30px;">&lt;jaxws:endpoint implementor=&#8221;demo.order. OrderProcessImpl&#8221; address=&#8221;/OrderProcess&#8221; &gt;</p>
<p style="padding-left: 30px;">&lt;jaxws:dataBinding&gt;</p>
<p style="padding-left: 30px;">&lt;bean class=&#8221;org.apache.cxf.aegis.databinding.AegisDatabinding&#8221; /&gt;</p>
<p style="padding-left: 30px;">&lt;/jaxws:dataBinding&gt;</p>
<p style="padding-left: 30px;">&lt;/jaxws:endpoint&gt;</p>
<p><strong>Protocol binding </strong></p>
<p>Bindings bind the web service&#8217;s messages with the protocol-specific format. The messages, in web service terminology, are nothing but an operation with input and output parameters. The message defined in the web service component is called a logical message. The logical message used by a service component is mapped or bound to a physical data format used by endpoints in the physical world.</p>
<p>Bindings are directly related to port types in a WSDL artifact. Port types define operations and input and output parameters which are abstract in nature. Port types define the logical message, whereas binding translates this logical message into actual payload data defined by the underlying protocol. The following WSDL portion shows the sample binding details:</p>
<p style="padding-left: 30px;">&lt;wsdl:binding name=&#8221;OrderProcessImplServiceSoapBinding&#8221; type=&#8221;tns:OrderProcess&#8221;&gt;</p>
<p style="padding-left: 30px;">&lt;soap:binding style=&#8221;document&#8221; transport= &#8220;http://schemas.xmlsoap.org/soap/http&#8221; /&gt;</p>
<p style="padding-left: 30px;">&lt;wsdl:operation&gt;</p>
<p style="padding-left: 30px;">&lt;soap:operation soapAction=&#8221;" style=&#8221;document&#8221; /&gt;</p>
<p style="padding-left: 30px;">&lt;wsdl:input&gt;</p>
<p style="padding-left: 30px;">&lt;soap:body use=&#8221;literal&#8221; /&gt;</p>
<p style="padding-left: 30px;">&lt;/wsdl:input&gt;</p>
<p style="padding-left: 30px;">&lt;wsdl:output name=&#8221;processOrderResponse&#8221;&gt;</p>
<p style="padding-left: 30px;">&lt;soap:body use=&#8221;literal&#8221; /&gt;</p>
<p style="padding-left: 30px;">&lt;/wsdl:output&gt;</p>
<p style="padding-left: 30px;">&lt;/wsdl:operation&gt;</p>
<p style="padding-left: 30px;">&lt;/wsdl:binding&gt;</p>
<p>As you can see from the above sample binding fragment, the binding is defined using the &lt;binding&gt; element. This element has two attributes, namely, name and type. The name attribute identifies the binding, and the type attribute maps it with the port type. The name attribute of the binding element is used to associate with the endpoint. The child elements of the &lt;binding&gt; parent element define the actual mapping of the messages with the protocol format. In the previous case, the communication protocol used is SOAP 1.1.</p>
<p>CXF supports the following binding protocols:</p>
<p>• SOAP 1.1</p>
<p>• SOAP 1.2</p>
<p>• CORBA</p>
<p>• Pure XML</p>
<p><strong>Transports </strong></p>
<p>Transport defines the high-level routing protocol to transmit the messages over the wire. Transport protocols are associated with the endpoints. One endpoint can communicate with another using a specific transport protocol. Transport details are nothing but networking details. Service endpoints are a physical representation of a service interface. Endpoints are composed of binding and networking details. In a WSDL artifact, transport details are specified as part of the &lt;port&gt; element. The port element is a child of the service element. The WSDL portion following shows the sample transport details:</p>
<p style="padding-left: 30px;">&lt;wsdl:service name=&#8221;OrderProcessImplService&#8221;&gt;</p>
<p style="padding-left: 30px;">&lt;wsdl:port binding=&#8221;tns:OrderProcessImplServiceSoapBinding&#8221; name=&#8221;OrderProcessImplPort&#8221;&gt;</p>
<p style="padding-left: 30px;">&lt;soap:address location=&#8221;http://localhost:8080/orderapp/ OrderProcess&#8221; /&gt;</p>
<p style="padding-left: 30px;">&lt;/wsdl:port&gt;</p>
<p style="padding-left: 30px;">&lt;/wsdl:service&gt;</p>
<p>As you see from the above XML fragment, transport details are specified as part of the service element. The service element has one child element as port element. The port element maps to binding as defined by the binding element and provides details of the transport. The previous example shows SOAP as binding protocol and HTTP as a transport protocol. In Chapter 4, the various transport protocols are explained in the context of web services development.</p>
<p>CXF supports the following transports for its endpoints:</p>
<p>• HTTP</p>
<p>• CORBA</p>
<p>• JMS</p>
<p>• Local</p>
<p><strong>Summary</strong></p>
<p>In this blog , we looked at the various components of the CXF Architecture. Each of these concepts , is explained in context of web service development through examples in Apache CXF Web Service CXF Book.</p>
<p>To know, more about how to develop SOAP and RESTful web services, get a copy of the Apache CXF Web Service Book -<a href="http://www.packtpub.com/apache-cxf-web-service-development/mid/2312092oq0d7?utm_source=cxf.soaweb.co.in&amp;utm_medium=affiliate&amp;utm_content=authorsite&amp;utm_campaign=mdb_001927" target="_blank"><div class="amzshcs" id="amzshcs-0ffe1990b5c22a8e10d5ec748e774099"><div class="amzshcs-item" id="amzshcs-item-b8543e78f0aeb0dd818a17e03e0b28ed"> <a href="http://www.amazon.com/Apache-CXF-Web-Service-Development/dp/1847195407%3FSubscriptionId%3DAKIAJWQLRXGXNE5KBGJA%26tag%3Dsw0fd-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D1847195407"><img src="http://ecx.images-amazon.com/images/I/51Sstnuk-CL._SL160_.jpg" height="160" width="130" alt="Image of Apache CXF Web Service Development" title="Apache CXF Web Service Development" /></a> </div></div> </a></p>
<p><script type="text/javascript">// <![CDATA[
   google_ad_client = "pub-3843887054708077"; /* 468x15, created 6/2/10 */ google_ad_slot = "8275571625"; google_ad_width = 468; google_ad_height = 15;
// ]]&gt;</script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script></p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Apache+CXF+web+service+framework+architecture+overview+http://cxf.soaweb.co.in/?p=146" title="Post to Twitter"><img class="nothumb" src="http://cxf.soaweb.co.in/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Apache+CXF+web+service+framework+architecture+overview+http://cxf.soaweb.co.in/?p=146" title="Post to Twitter">Tweet This Post</a> <a class="tt" href="http://delicious.com/post?url=http://cxf.soaweb.co.in/index.php/2010/01/23/apache-cxf-webservice-framework-architecture-overview/&amp;title=Apache+CXF+web+service+framework+architecture+overview" title="Post to Delicious"><img class="nothumb" src="http://cxf.soaweb.co.in/wp-content/plugins/tweet-this/icons/tt-delicious.png" alt="Post to Delicious" /></a> <a class="tt" href="http://delicious.com/post?url=http://cxf.soaweb.co.in/index.php/2010/01/23/apache-cxf-webservice-framework-architecture-overview/&amp;title=Apache+CXF+web+service+framework+architecture+overview" title="Post to Delicious">Delicious</a> <a class="tt" href="http://digg.com/submit?url=http://cxf.soaweb.co.in/index.php/2010/01/23/apache-cxf-webservice-framework-architecture-overview/&amp;title=Apache+CXF+web+service+framework+architecture+overview" title="Post to Digg"><img class="nothumb" src="http://cxf.soaweb.co.in/wp-content/plugins/tweet-this/icons/tt-digg.png" alt="Post to Digg" /></a> <a class="tt" href="http://digg.com/submit?url=http://cxf.soaweb.co.in/index.php/2010/01/23/apache-cxf-webservice-framework-architecture-overview/&amp;title=Apache+CXF+web+service+framework+architecture+overview" title="Post to Digg">Digg This Post</a></p>]]></content:encoded>
			<wfw:commentRss>http://cxf.soaweb.co.in/index.php/2010/01/23/apache-cxf-webservice-framework-architecture-overview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Develop simple web service with CXF and Spring</title>
		<link>http://cxf.soaweb.co.in/index.php/2010/01/18/develop-simple-web-service-with-cxf-and-spring/</link>
		<comments>http://cxf.soaweb.co.in/index.php/2010/01/18/develop-simple-web-service-with-cxf-and-spring/#comments</comments>
		<pubDate>Mon, 18 Jan 2010 11:14:49 +0000</pubDate>
		<dc:creator>Naveen</dc:creator>
				<category><![CDATA[CXF Services Book]]></category>
		<category><![CDATA[CXF example]]></category>
		<category><![CDATA[CXF Tutorial]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://cxf.soaweb.co.in/?p=132</guid>
		<description><![CDATA[// 


 
 
In this blog we will look at how to develop a simple web service using CXF and Spring-based configurations. We will take a use case of a Order Processing Application and than develop a web service and client for this use case.
The Order Processing Application
The objective of the Order Processing Application is [...]]]></description>
			<content:encoded><![CDATA[<p><script type="text/javascript">// <![CDATA[
   google_ad_client = "pub-3843887054708077"; /* 468x15, created 6/2/10 */ google_ad_slot = "8275571625"; google_ad_width = 468; google_ad_height = 15;
// ]]&gt;</script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script></p>
<blockquote><p><em> </em></p>
<p><em> </em></p></blockquote>
<p>In this blog we will look at how to develop a simple web service using CXF and <em>Spring-based configurations</em>. We will take a use case of a Order Processing Application and than develop a web service and client for this use case.</p>
<p><strong>The Order Processing Application</strong></p>
<p>The objective of the Order Processing Application is to process a customer  order. The order process functionality will generate the customer order, thereby  making the order valid and approved. A typical scenario will be a customer  making an order request to buy a particular item. The purchase department will  receive the order request from the customer and prepare a formal purchase order.  The purchase order will hold the details of the customer, the name of the item  to be purchased, the quantity, and the price. Once the order is prepared, it  will be sent to the Order Processing department for the necessary approval. If  the order is valid and approved, then the department will generate the unique  order ID and send it back to the Purchase department. The Purchase department  will communicate the order ID back to the customer.</p>
<p><img class="alignleft size-full wp-image-133" title="Order Process" src="http://cxf.soaweb.co.in/wp-content/uploads/2010/01/5401_02_image01.png" alt="Order Process" width="228" height="100" /> For simplicity, we will look at the following use cases:</p>
<p>- Prepare an order</p>
<p>- Place the order</p>
<p>The client application will prepare an order and send it to the server  application through a business method call. The server application will contain  a web service that will process the order and generate a unique order ID. The  generation of the unique order ID will signify order approval.</p>
<p style="margin-left: 40px; margin-right: 40px;"><em>In real world applications  a unique order ID is always accompanied by the date the order was approved.  However, in this example we chose to keep it simple by only generating order  ID.</em></p>
<p><strong>Developing a service</strong></p>
<p>Let&#8217;s look specifically at how to create an Order Processing Web Service and  then register it as a Spring bean using a JAX-WS frontend.</p>
<p style="margin-left: 40px; margin-right: 40px;"><em>The Sun-based JAX-WS  specification can be found at the following URL: <a href="http://jcp.org/aboutJava/communityprocess/final/jsr224/index.html" target="blank">http://jcp.org/aboutJava/communityprocess/final/jsr224/index.html</a></em></p>
<p>JAX-WS frontend offers two ways of developing a web service—Code-first and  Contract-first. We will use the <em>Code-first</em> approach, that is, we will  first create a Java class and convert this into a web service component. The  first set of tasks will be to create server-side components.</p>
<p style="margin-left: 40px; margin-right: 40px;"><em>In web service terminology,  Code-first is termed as the Bottoms Up approach, and Contract-first is referred  to as the Top Down approach.</em></p>
<p>To achieve this, we typically perform the following steps:</p>
<ul>
<li>Create a <strong>Service Endpoint Interface (SEI)</strong> and define a business  method to be used with the web service.</li>
<li>Create the implementation class and annotate it as a web service.</li>
<li>Create beans.xml and define the service class as a Spring bean using a  JAX-WS frontend.</li>
</ul>
<p><strong>Creating a Service Endpoint Interface (SEI)</strong></p>
<p>Let&#8217;s first create the SEI for our Order Processing Application. We will name  our SEI <em>OrderProcess</em>. The following code illustrates the  <em>OrderProcess</em> SEI:</p>
<pre style="margin-left: 40px;">package demo.order;
import javax.jws.WebService;
@WebService
public interface OrderProcess {
  @WebMethod
  String processOrder(Order order);
}</pre>
<p>As you can see from the preceding code, we created a Service Endpoint  Interface named <em>OrderProcess</em>. The SEI is just like any other Java  interface. It defines an abstract business method <em>processOrder</em>. The  method takes an Order bean as a parameter and returns an order ID String value.  The goal of the <em>processOrder</em> method is to process the order placed by  the customer and return the unique order ID.</p>
<p>One significant thing to observe is the <em>@WebService</em> annotation. The  annotation is placed right above the interface definition. It signifies that  this interface is not an ordinary interface but a web service interface. This  interface is known as <strong>Service Endpoint Interface</strong> and will have a business  method exposed as a service method to be invoked by the client.</p>
<p>The <em>@WebService</em> annotation is part of the JAX-WS annotation library.  JAX-WS provides a library of annotations to turn Plain Old Java classes into web  services and specifies detailed mapping from a service defined in WSDL to the  Java classes that will implement that service. The <em>javax.jws.WebService</em> annotation also comes with attributes that completely define a web service. For  the moment we will ignore these attributes and proceed with our development.</p>
<p>The <em>javax.jws.@WebMethod</em> annotation is optional and is used for  customizing the web service operation. The <em>@WebMethod</em> annotation  provides the operation name and the action elements which are used to customize  the <em>name</em> attribute of the operation and the SOAP action element in the  WSDL document.</p>
<p>The following code shows the <em>Order</em> class:</p>
<pre style="margin-left: 40px;">package demo.order;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "Order")
public class Order {
  private String customerID;
  private String itemID;
  private int qty;
  private double price;
  // Contructor
  public Order() {
  }
  public String getCustomerID() {
    return customerID;
  }
  public void setCustomerID(String customerID) {
    this.customerID = customerID;
  }
  public String getItemID() {
    return itemID;
  }
  public void setItemID(String itemID) {
    this.itemID = itemID;
  }
  public int getQty() {
    return qty;
  }
  public void setQty(int qty) {
    this.qty = qty;
  }
  public double getPrice() {
    return price;
  }
  public void setPrice(double price) {
    this.price = price;
  }
}</pre>
<p>As you can see, we have added an <em>@XmlRootElement</em> annotation to the  <em>Order</em> class. The <em>@XmlRootElement</em> is part of the <strong>Java  Architecture for XML Binding (JAXB)</strong> annotation library. JAXB provides data  binding capabilities by providing a convenient way to map XML schema to a  representation in Java code. The JAXB shields the conversion of XML schema  messages in SOAP messages to Java code without having the developers know about  XML and SOAP parsing. CXF uses JAXB as the default data binding component.</p>
<p>The <em>@XmlRootElement</em> annotations associated with <em>Order</em> class  map the <em>Order</em> class to the XML root element. The attributes contained  within the <em>Order</em> object by default are mapped to <em>@XmlElement</em>.  The <em>@XmlElement</em> annotations are used to define elements within the XML.  The <em>@XmlRootElement</em> and <em>@XmlElement</em> annotations allow you to  customize the namespace and name of the XML element. If no customizations are  provided, then the JAXB runtime by default would use the same name of attribute  for the XML element. CXF handles this mapping of Java objects to XML using the JAXB Binding.</p>
<p><strong>Developing a service implementation class</strong></p>
<p>We will now develop the implementation class that will realize our  <em>OrderProcess</em> SEI. We will name this implementation class  <em>OrderProcessImpl</em>. The following code illustrates the service  implementation class <em>OrderProcessImpl</em>:</p>
<pre style="margin-left: 40px;">@WebService
public class OrderProcessImpl implements OrderProcess {
  public String processOrder(Order order) {
    String orderID = validate(order);
      return orderID;
  }
/**
 * Validates the order and returns the order ID
**/
  private String validate(Order order) {
    String custID = order.getCustomerID();
    String itemID = order.getItemID();
    int qty = order.getQty();
    double price = order.getPrice();
    if (custID != null &amp;&amp; itemID != null &amp;&amp; !custID.equals("")
                       &amp;&amp; !itemID.equals("") &amp;&amp; qty &gt; 0
                       &amp;&amp; price &gt; 0.0) {
        return "ORD1234";
    }
    return null;
  }
}</pre>
<p>As we can see from the preceding code, our implementation class  <em>OrderProcessImpl</em> is pretty straightforward. It also has  <em>@WebService</em> annotation defined above the class declaration. The class  <em>OrderProcessImpl</em> implements <em>OrderProcess</em> SEI. The class  implements the <em>processOrder</em> method. The <em>processOrder</em> method  checks for the validity of the order by invoking the <em>validate</em> method.  The <em>validate</em> method checks whether the <em>Order</em> bean has all the  relevant properties valid and not null.</p>
<p>Next we will look at how to publish the OrderProcess JAX-WS web service using  Spring configuration.</p>
<p><strong>Spring-based server bean</strong></p>
<p>What makes CXF the obvious choice as a web service framework is its use of  Spring-based configuration files to publish web service endpoints. It is the use  of such configuration files that makes the development of web service convenient  and easy with CXF.</p>
<p>Spring provides a lightweight container which works on the concept of  <strong>Inversion of Control (IoC)</strong> or <strong>Dependency Injection (DI)</strong> architecture; it does so through the implementation of a configuration file that  defines Java beans and its dependencies. By using Spring you can abstract and  wire all the class dependencies in a single configuration file. The  configuration file is often referred to as an Application Context or Bean  Context file.</p>
<p>We will create a server side Spring-based configuration file and name it as  <em>beans.xml</em>. The following code illustrates the <em>beans.xml</em> configuration file:</p>
<pre style="margin-left: 40px;">&lt;beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:jaxws="http://cxf.apache.org/jaxws"
  xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd"&gt;
  &lt;import resource="classpath:META-INF/cxf/cxf.xml" /&gt;
  &lt;import resource="classpath:META-INF/cxf/cxf-extension-    soap.xml" /&gt;
  &lt;import resource="classpath:META-INF/cxf/cxf-servlet.xml" /&gt;
  &lt;jaxws:endpoint
    id="orderProcess"
    implementor="demo.order.OrderProcessImpl"
    address="/OrderProcess" /&gt;
&lt;/beans&gt;</pre>
<p>Let&#8217;s examine the previous code and understand what it really means. It first  defines the necessary namespaces. It then defines a series of  <em>&lt;import&gt;</em> statements. It imports <em>cxf.xml</em>,  <em>cxf-extension-soap.xml</em>, and <em>cxf-servlet.xml</em>. These files are  Springbased configuration files that define core components of CXF. They are  used to kick start CXF runtime and load the necessary infrastructure objects  such as WSDL manager, conduit manager, destination factory manager, and so  on.</p>
<p>The <em>&lt;jaxws:endpoint&gt;</em> element in the <em>beans.xml</em> file  specifies the <em>OrderProcess</em> web service as a JAX-WS  endpoint. The  element is defined with the following three attributes:</p>
<ul>
<li><em>id</em>—specifies a unique identifier for a bean. In this case,  <em>jaxws:endpoint</em> is a bean, and the <em>id</em> name is  <em>orderProcess</em>.</li>
<li><em>implementor</em>— specifies the actual web service implementation class.  In this case, our implementor class is <em>OrderProcessImpl</em>.</li>
<li><em>address</em>— specifies the URL address where the endpoint is to be  published. The URL address must to be relative to the web context. For our  example, the endpoint will be published using the relative path  <em>/OrderProcess</em>.</li>
</ul>
<p>The <em>&lt;jaxws:endpoint&gt;</em> element signifies that the CXF internally  uses JAX-WS frontend to publish the web service. This element definition  provides a short and convenient way to publish a web service. A developer need  not have to write any Java class to publish a web service.</p>
<p><strong>Developing a client</strong></p>
<p>In the previous section we discussed and illustrated how to develop and  publish a web service. We now have the server-side code that publishes our  <em>OrderProcess</em> web service. The next set of tasks will be to create the  client-side code that will consume or invoke our <em>OrderProcess</em> web  service. To achieve this, we will perform the following steps:</p>
<ul>
<li>Develop the client-beans.xml to define the client factory class as a Spring  bean using JAX-WS frontend</li>
<li>Develop a client Java application to invoke the web service</li>
</ul>
<p><strong>Developing a Spring-based client bean</strong></p>
<p>We will create a client-side Spring-based configuration file and name it as  <em>client-beans.xml</em>. The following code illustrates the  <em>client-beans.xml</em> configuration file:</p>
<pre style="margin-left: 40px;">&lt;beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:jaxws="http://cxf.apache.org/jaxws"
  xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd"&gt;
&lt;jaxws:client id="orderClient" serviceClass=
                 "demo.order.OrderProcess" address=
                 "http://localhost:8080/orderapp/OrderProcess" /&gt;
&lt;/beans&gt;</pre>
<p>The <em>&lt;jaxws:client&gt;</em> element in the <em>client-beans.xml</em> file specifies the client bean using JAX-WS frontend. The element is defined  with the following three attributes:</p>
<ul>
<li><em>id</em>—specifies a unique identifier for a bean. In this case,  <em>jaxws:client</em> is a bean and the <em>id</em> name is  <em>orderClient</em>. The bean will represent an SEI.</li>
<li><em>serviceClass</em>—specifies the web service SEI. In this case our SEI  class is <em>OrderProcess</em></li>
<li><em>address</em>—specifies the URL address where the endpoint is published.  In this case the endpoint is published at the URL address:  <em>http://localhost:8080/orderapp/OrderProcess</em></li>
</ul>
<p><em>&lt;jaxws:client&gt;</em> signifies the client bean that represents an  <em>OrderProcess</em> SEI. The client application will make use of this SEI to  invoke the web service. Again, CXF internally uses JAX-WS frontend to define  this client-side component.</p>
<p><strong>Developing web service client code</strong></p>
<p>We will now create a standalone Java class to invoke our  <em>OrderProcess</em> web service. The following code illustrates the client  invocation of a web service method:</p>
<pre style="margin-left: 40px;">public final class Client {
  public Client() {
  }
  public static void main(String args[]) throws Exception {
    // START SNIPPET: client
    ClassPathXmlApplicationContext context
        = new ClassPathXmlApplicationContext(new String[]
               {"demo/order/client/client-beans.xml"});
    OrderProcess client = (OrderProcess) context.
                          getBean("orderClient");
  // Populate the Order bean
  Order order = new Order();
  order.setCustomerID("C001");
  order.setItemID("I001");
  order.setQty(100);
  order.setPrice(200.00);
    String orderID = client.processOrder(order);
    String message = (orderID == null) ?
                     "Order not approved" : "Order approved;
                      order ID is " + orderID;
    System.out.println(message);
    System.exit(0);</pre>
<p>As you can see from the above code, we have the <em>main</em> method that  first loads the <em>client-beans.xml</em> configuration file. It uses the Spring  application context component <em>ClassPathXmlApplicationContext</em> to load  the configuration file. The context component&#8217;s <em>getBean</em> method is  passed the bean ID <em>orderClient</em>. This method will return the  <em>OrderProcess</em> SEIcomponent. Using the SEI, we then invoke the web  service method <em>processOrder</em>. One thing to observe here is that the  client always uses the interface to invoke a web service method.</p>
<p>We have now finished developing server and client side components. To  summarize, we created the <em>OrderProcess</em> service endpoint interface and  the implementation class. We then created server and client-side Spring-based  configuration files and finally we created the client application. The relevant  components are developed and we are all set to run or execute our code. But  before we do that, you will have to create one final component that will  integrate Spring and CXF.</p>
<p>We need to wire Spring and CXF through <em>web.xml</em>. The following code  illustrates the <em>web.xml</em> file:</p>
<pre style="margin-left: 40px;">&lt;web-app&gt;
  &lt;context-param&gt;
    &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
    &lt;param-value&gt;WEB-INF/beans.xml&lt;/param-value&gt;
  &lt;/context-param&gt;
  &lt;listener&gt;
    &lt;listener-class&gt;
      org.springframework.web.context.ContextLoaderListener
    &lt;/listener-class&gt;
  &lt;/listener&gt;
  &lt;servlet&gt;
    &lt;servlet-name&gt;CXFServlet&lt;/servlet-name&gt;
    &lt;display-name&gt;CXF Servlet&lt;/display-name&gt;
    &lt;servlet-class&gt;
      org.apache.cxf.transport.servlet.CXFServlet
    &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;CXFServlet&lt;/servlet-name&gt;
    &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
&lt;/web-app&gt;</pre>
<p>Let&#8217;s go through the above piece of code. The <em>web.xml</em>, as we know,  is the web application configuration file that defines a servlet and its  properties. The file defines <em>CXFServlet</em>, which acts as a front runner  component that initiates the CXF environment. It defines the <em>listener</em> class <em>ContextLoaderListener</em>, which is responsible for loading the  server-side configuration file <em>beans.xml</em>. So upon the web server  startup, the order process web service endpoint will be registered and  published.</p>
<p><strong>Running the program</strong></p>
<p>Before running the program, we will organize the code so far developed in the appropriate folder structure. You can create the folder structure, as shown in the following screenshot, and put the components in the respective sub folders. Following shows the code layout  of the project</p>
<p><img class="aligncenter size-full wp-image-138" title="CXF Book Image" src="http://cxf.soaweb.co.in/wp-content/uploads/2010/01/5401_02_image21.jpg" alt="CXF Book Image" width="333" height="224" /></p>
<p>The developed code will go into the following:</p>
<ul>
<li>The Java code will go into the respective package folders</li>
<li>The <em>beans.xml</em> and <em>web.xml</em> will go into the  <em>webapp\WEB-INF</em> folder (the folder name &#8211; WEB-INF should be in caps)</li>
<li>The <em>client-beans.xml</em> file will go into the <em>demoorderclient</em> folder</li>
</ul>
<p>Once the code is organized, we will go about building and deploying it in the  Tomcat server. It will typically involve three steps:</p>
<ul>
<li>Building the code</li>
<li>Deploying the code</li>
<li>Executing the code</li>
</ul>
<p><strong>Building the code</strong></p>
<p>Building the code means compiling the source Java code. We will use the ANT  tool to do this. The ANT file is provided in <em>Chapter2orderapp</em> folder.  The following code illustrates the sample <em>build.xml</em> build script:</p>
<pre style="margin-left: 40px;">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;project name="CXF Chapter2 example" default="build" basedir="."&gt;
  &lt;import file="common_build.xml"/&gt;
    &lt;target name="client" description=
                 "run demo client" depends="build"&gt;
        &lt;property name="param" value=""/&gt;
        &lt;cxfrun classname="demo.order.client.Client" /&gt;
    &lt;/target&gt;
    &lt;target name="server" description=
                 "run demo server" depends="build"&gt;
        &lt;cxfrun classname="demo.spring.servlet.Server"/&gt;
    &lt;/target&gt;
    &lt;property name="cxf.war.file.name" value="orderapp"/&gt;
      &lt;target name="war" depends="build"&gt;
    &lt;cxfwar filename="${cxf.war.file.name}.war" webxml=
                     "webapp/WEB-INF/web.xml" /&gt;
    &lt;/target&gt;
&lt;/project&gt;</pre>
<p>Alongside <em>build.xml</em>, you will also find <em>common_build.xml</em> in  the same folder. The <em>common_buid.xml</em> refers to <em>CATALINA_HOME</em> environment variable to find location of tomcat installation. Please set <em>CATALINA_HOME </em>environment to point to tomcat installation installation. Open  the command prompt window, go to <em>C:/orderapp</em> folder and run the  <strong>ant</strong> command. It will build the code and put the class files under the  newly created <em>build</em> folder. The following figure shows the output  generated upon running the <em>ant</em> command.</p>
<p><strong>Deploying the code</strong></p>
<p>Having built the code, we will deploy it. Deployment effectively means  building and moving the code archive to the server deploy path. We will be using  the Tomcat web container to deploy and run the application. To deploy our built  code, navigate to<em> project root</em> folder, and enter the following  command:</p>
<pre style="margin-left: 40px;">ant deploy<strong>
</strong></pre>
<p>This will build the WAR file and put it under the Tomcat server  <em>webapp</em> path. For example, if you have installed the Tomcat under the  root folder, then the WAR will be deployed to <em>/Tomcat/webapp</em> folder.</p>
<p><strong>Executing the code</strong></p>
<p>Following code deployment, we are all set to run the Order Process  Application. You will execute the Java client program <em>Client.java</em> to  invoke the Order Process web service. The program will invoke the  <em>processOrder</em> method that will generate the order ID if the specified  order is approved. Before running the client program, we need to start the  Tomcat web server. There are several ways of starting the Tomcat server  depending on the Tomcat version that is installed. Once the server is started,  you need to run the client program by giving the following command at the  command prompt window:</p>
<pre style="margin-left: 40px;">ant client<strong>
</strong></pre>
<p>Upon  executing this command, it will generate the following output:</p>
<p><img class="aligncenter size-full wp-image-139" title="CXF Web Service Output" src="http://cxf.soaweb.co.in/wp-content/uploads/2010/01/5401_02_image3.gif" alt="CXF Web Service Output" width="503" height="229" /></p>
<p>Thus we have successfully executed the order processing web  service.</p>
<p><strong>Summary</strong></p>
<p>In this blog we provided an overview of a sample Order Processing Application  and saw how to develop a web service with Spring-based configuration. We also  saw how to build, deploy, and execute a web service using ANT and Tomcat.</p>
<p><script type="text/javascript">// <![CDATA[
   google_ad_client = "pub-3843887054708077"; /* 468x15, created 6/2/10 */ google_ad_slot = "8275571625"; google_ad_width = 468; google_ad_height = 15;
// ]]&gt;</script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script></p>
<p>To know, more about how to develop SOAP and RESTful web services, get a copy of the Apache CXF Web Service Book -</p>
<p><a href="http://www.packtpub.com/apache-cxf-web-service-development/mid/2312092oq0d7?utm_source=cxf.soaweb.co.in&amp;utm_medium=affiliate&amp;utm_content=authorsite&amp;utm_campaign=mdb_001927" target="_blank"><div class="amzshcs" id="amzshcs-0ffe1990b5c22a8e10d5ec748e774099"><div class="amzshcs-item" id="amzshcs-item-b8543e78f0aeb0dd818a17e03e0b28ed"> <a href="http://www.amazon.com/Apache-CXF-Web-Service-Development/dp/1847195407%3FSubscriptionId%3DAKIAJWQLRXGXNE5KBGJA%26tag%3Dsw0fd-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D1847195407"><img src="http://ecx.images-amazon.com/images/I/51Sstnuk-CL._SL160_.jpg" height="160" width="130" alt="Image of Apache CXF Web Service Development" title="Apache CXF Web Service Development" /></a> </div></div> </a></p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Develop+simple+web+service+with+CXF+and+Spring+http://cxf.soaweb.co.in/?p=132" title="Post to Twitter"><img class="nothumb" src="http://cxf.soaweb.co.in/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Develop+simple+web+service+with+CXF+and+Spring+http://cxf.soaweb.co.in/?p=132" title="Post to Twitter">Tweet This Post</a> <a class="tt" href="http://delicious.com/post?url=http://cxf.soaweb.co.in/index.php/2010/01/18/develop-simple-web-service-with-cxf-and-spring/&amp;title=Develop+simple+web+service+with+CXF+and+Spring" title="Post to Delicious"><img class="nothumb" src="http://cxf.soaweb.co.in/wp-content/plugins/tweet-this/icons/tt-delicious.png" alt="Post to Delicious" /></a> <a class="tt" href="http://delicious.com/post?url=http://cxf.soaweb.co.in/index.php/2010/01/18/develop-simple-web-service-with-cxf-and-spring/&amp;title=Develop+simple+web+service+with+CXF+and+Spring" title="Post to Delicious">Delicious</a> <a class="tt" href="http://digg.com/submit?url=http://cxf.soaweb.co.in/index.php/2010/01/18/develop-simple-web-service-with-cxf-and-spring/&amp;title=Develop+simple+web+service+with+CXF+and+Spring" title="Post to Digg"><img class="nothumb" src="http://cxf.soaweb.co.in/wp-content/plugins/tweet-this/icons/tt-digg.png" alt="Post to Digg" /></a> <a class="tt" href="http://digg.com/submit?url=http://cxf.soaweb.co.in/index.php/2010/01/18/develop-simple-web-service-with-cxf-and-spring/&amp;title=Develop+simple+web+service+with+CXF+and+Spring" title="Post to Digg">Digg This Post</a></p>]]></content:encoded>
			<wfw:commentRss>http://cxf.soaweb.co.in/index.php/2010/01/18/develop-simple-web-service-with-cxf-and-spring/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Invoking .NET Web Service using CXF Apache WSDL2Java Tool</title>
		<link>http://cxf.soaweb.co.in/index.php/2010/01/16/invoking-net-web-service-using-cxf-apache-wsdl2java-tool/</link>
		<comments>http://cxf.soaweb.co.in/index.php/2010/01/16/invoking-net-web-service-using-cxf-apache-wsdl2java-tool/#comments</comments>
		<pubDate>Sat, 16 Jan 2010 09:02:08 +0000</pubDate>
		<dc:creator>Naveen</dc:creator>
				<category><![CDATA[CXF Services Book]]></category>
		<category><![CDATA[CXF Tutorial]]></category>
		<category><![CDATA[WSDL2Java]]></category>

		<guid isPermaLink="false">http://cxf.soaweb.co.in/?p=99</guid>
		<description><![CDATA[The CXF framework provides various tools that assist developers in creating and invoking web services. CXF provides tools to create web service clients and web service implementations from WSDL files, to create SOAP binding and service definition from WSDL interfaces, to validate WSDL files, and to integrate with the popular Apache Maven software tool for [...]]]></description>
			<content:encoded><![CDATA[<p>The CXF framework provides various tools that assist developers in creating and invoking web services. CXF provides tools to create web service clients and web service implementations from WSDL files, to create SOAP binding and service definition from WSDL interfaces, to validate WSDL files, and to integrate with the popular Apache Maven software tool for build management. In this blog, we will look at how to invoke a .NET web service using Java client artifacts generated using the CXF Apache WSDL2Java Tool .</p>
<p><strong>Invoking a web service using the Java client<br />
</strong>A web service exposes a set of operations over the network, typically via HTTP protocol. In order to invoke the web services, the web service client needs to know the following information:</p>
<ul>
<li>What operations are exposed by the web service</li>
<li>The input and output message formats required to access the service operations</li>
<li>What protocol, for instance HTTP or JMS, to use to invoke the web service</li>
<li>The URL location of the web service</li>
</ul>
<p>All of the above information is contained in the standard XML descriptor called WSDL (Web Service Description Language). The WSDL file provides a format contract between the web service provider and the web service client. The web service client typically inspects the WSDL file to determine what operations are exposed by the web service, what parameters need to be supplied to invoke the web service operation and to formulate the request, and invokes the web service over the supported protocol. Similarly, the web service clients need to write the code to inspect the response and convert it into the required format. CXF hides the complexity of creating web service clients by providing the WSDL to Java command line tool, which takes a WSDL file and generates client code. The client code can be used by developers with no changes to invoke the web services.</p>
<p>In this blog, we will look at how to generate client code from an existing WSDL. We will invoke a  <em>.NET</em> service located over the Web, using the Java client generated by the WSDL to Java tool. This shows the true power of web service interoperability, where applications implemented in different languages can communicate with each other.</p>
<p style="MARGIN-LEFT: 40px; MARGIN-RIGHT: 40px"><em>The process of generating web service clients does not differ for web services implemented in different languages, as you generate web service clients from WSDL and XML Schema definitions.</em></p>
<p>Before invoking the .NET service, let&#8217;s examine the WSDL to determine which operations are exposed by the web service.</p>
<p><strong>Analyzing the service WSDL definition</strong></p>
<p>We will invoke a publicly available .NET web service located at <a href="http://www.ignyte.com/webservices/ignyte.whatsshowing.webservice/moviefunctions.asmx?wsdl" target="blank">http://www.ignyte.com/webservices/ignyte.whatsshowing.webservice/moviefunctions.asmx?wsdl</a>. This web service retrieves US Theaters and Movie Showtime information based on a valid US zip code and a radius supplied by the web service clients.</p>
<p style="MARGIN-LEFT: 40px; MARGIN-RIGHT: 40px"><em>The .NET web service is a <strong>WS-I</strong> compliant web service.</em></p>
<p>The <strong>Web Services Interoperability Organization (WS-I)</strong>, an open industry organization, was formed to promote web services interoperability across platforms, operating systems, and programming languages. One concrete product of WS-I is the <strong>Basic Profile</strong>. Basic Profile narrows the scope of specifications to a reasonable set of rules and guidelines that are best suited to help interoperability.</p>
<p>If you type in the given URL in the browser, you see the WSDL definition, as shown in the following screenshot:</p>
<p><img class="alignnone size-full wp-image-102" title="MovieService WSDL" src="http://cxf.soaweb.co.in/wp-content/uploads/2010/01/5401_08_01.png" alt="MovieService WSDL" width="800" height="600" /></p>
<p>Let&#8217;s analyze the important sections of the WSDL file to get an understanding of which operations are exposed by the movie information web service and which message formats are required to invoke the web service.</p>
<p>The web service provides two operations, <em>GetTheatersAndMovies</em> and <em>GetUpcomingMovies</em>, as shown in listing below. For this tutorial, we will focus on how to invoke the <em>GetTheatersAndMovies</em> operation. The <em>GetTheatersAndMovies</em> takes the <em>GetTheatersAndMoviesSoapIn</em> message as the input and provides <em>GetTheatersAndMoviesSoapOut</em> as the output message.</p>
<p style="PADDING-LEFT: 30px; TEXT-ALIGN: left">&lt;wsdl:portType name=&#8221;MovieInformationSoap&#8221;&gt;<br />
&lt;wsdl:operation name=&#8221;GetTheatersAndMovies&#8221;&gt;<br />
&lt;wsdl:documentation xmlns:wsdl=&#8221;http://schemas.xmlsoap.org/<br />
wsdl/&#8221;&gt;This method will retrieve a list of all theaters and the movies<br />
playing today.&lt;/wsdl:documentation&gt;<br />
&lt;wsdl:input message=&#8221;tns:GetTheatersAndMoviesSoapIn&#8221; /&gt;<br />
&lt;wsdl:output message=&#8221;tns:GetTheatersAndMoviesSoapOut&#8221; /&gt;<br />
&lt;/wsdl:operation&gt;<br />
&lt;/wsdl:portType&gt;</p>
<p>The web service client invokes the <em>GetTheatersAndMovies</em> operation to get theater and movie information. The input to the <em>GetTheatersAndMovies</em> operation is the <em>GetTheatersAndMoviesSoapIn</em> XML message.</p>
<p>The <em>GetTheatersAndMoviesSoapIn</em> message references the <em>GetTheatersAndMovies</em> element, which defines the actual XML schema definition for the input message. The following is the code listing of <em>GetTheatersAndMovies</em> schema definition:</p>
<pre style="PADDING-LEFT: 30px">&lt;s:element name="GetTheatersAndMovies"&gt;
  &lt;s:complexType&gt;
    &lt;s:sequence&gt;
      &lt;s:element minOccurs="0" maxOccurs="1"
      name="zipCode" type="s:string" /&gt;
      &lt;s:element minOccurs="1" maxOccurs="1"
      name="radius" type="s:int" /&gt;
    &lt;/s:sequence&gt;
  &lt;/s:complexType&gt;
&lt;/s:element&gt;</pre>
<p style="text-align: left;">The GetTheatersAndMovies contains an element zipCode of type String and radius which is of type integer that needs to be passed as input by the web services client as an input to the GetTheatersAndMoviesSoapIn operation. The minOccurs and maxOccurs attribute associated with zipCode and radius is used to specify the minimum and maximum occurrence of the element inside a GetTheatersAndMovies element. The zipCode and radius element can appear only once inside a GetTheatersAndMovies element as it specifies the value of maxOccurs=&#8221;1&#8243;. If maxOccurs has the value Unbounded, then it implies that multiple occurrences of the element can exist.Similarly, the GetTheatersAndMoviesResponse specifies the output message format for the response. The following is the code listing of the GetTheatersAndMoviesResponse schema definition. We will break down the schema for better understanding:</p>
<ul>
<li>The <em>GetTheatersAndMoviesResponse</em> schema<br />
The following shows the definition of <em>GetTheatersAndMoviesResponse</em>. The <em>GetTheatersAndMoviesResponse</em> contains an element <em>ArrayOfTheater</em></li>
</ul>
<p style="PADDING-LEFT: 60px">&lt;s:element name=&#8221;GetTheatersAndMoviesResponse&#8221;&gt;<br />
&lt;s:complexType&gt;<br />
&lt;s:sequence&gt;<br />
&lt;s:element minOccurs=&#8221;0&#8243; maxOccurs=&#8221;1&#8243;<br />
name=&#8221;GetTheatersAndMoviesResult&#8221; type=<br />
&#8220;tns:ArrayOfTheater&#8221; /&gt;<br />
&lt;/s:sequence&gt;<br />
&lt;/s:complexType&gt;<br />
&lt;/s:element&gt;</p>
<ul>
<li>The <em>ArrayOfTheater</em> Schema<br />
The following shows the definition of <em>ArrayOfTheater</em> schema.<br />
The <em>ArrayOfTheater</em> is an array which consists of <em>Theatre</em> elements.<br />
The <em>maxOccurs=&#8221;unbounded&#8221;</em> specifies that multiple occurrences of <em>Theatre</em> elements can exist in an <em>ArrayOfTheater</em> element.</li>
</ul>
<p style="PADDING-LEFT: 60px">&lt;s:complexType name=&#8221;ArrayOfTheater&#8221;&gt;<br />
&lt;s:sequence&gt;<br />
&lt;s:element minOccurs=&#8221;0&#8243; maxOccurs=<br />
&#8220;unbounded&#8221; name=&#8221;Theater&#8221; nillable=<br />
&#8220;true&#8221; type=&#8221;tns:Theater&#8221; /&gt;<br />
&lt;/s:sequence&gt;<br />
&lt;/s:complexType&gt;</p>
<p style="padding-left: 30px;">The <em>Theater</em> elements consist of the <em>Name</em> and <em>Address</em> elements of type <em>String</em>, which specifies the name and address of the<em> Theater</em> and an array of <em>ArrayOfMovie</em> element.</p>
<ul>
<li>
<div>The <em>ArrayOfMovie</em> Schema<br />
The following is the <em>ArrayOfMovie</em> definition. The <em>ArrayOfMovie</em> is an array which consists of <em>Movie</em> elements. The <em>maxOccurs=&#8221;unbounded&#8221;</em> specifies that multiple occurrences of <em>Movie</em> elements can exist in an <em>ArrayOfMovie</em> element.</div>
</li>
</ul>
<pre style="PADDING-LEFT: 30px; MARGIN-LEFT: 40px">&lt;s:complexType name="ArrayOfMovie"&gt;
  &lt;s:sequence&gt;
    &lt;s:element minOccurs="0" maxOccurs=
    "unbounded" name="Movie" nillable=
    "true" type="tns:Movie" /&gt;
  &lt;/s:sequence&gt;
&lt;/s:complexType&gt;</pre>
<p>Based on the Schema definitions above, the CXF WSDL2Java tool generates Java code that maps to these XML elements. The web service clients communicate with the web services using these generated Java objects to invoke a Java method representing the GetTheatersAndMoviesoperation and leave the SOAP XML to Java conversion and low level implementation details with the CXF framework.The SOAP address in the WSDL file specifies the location of the service, which is <a href="http://www.ignyte.com/webservices/ignyte.whatsshowing.webservice/moviefunctions.asmx" target="_blank">http://www.ignyte.com/webservices/ignyte.whatsshowing.webservice/moviefunctions.asmx</a>, as shown in the listing below:</p>
<p style="PADDING-LEFT: 90px">&lt;wsdl:service name=&#8221;MovieInformation&#8221;&gt;<br />
&lt;wsdl:port name=&#8221;MovieInformationSoap&#8221; binding=<br />
&#8220;tns:MovieInformationSoap&#8221;&gt;<br />
<span style="FONT-WEIGHT: bold">&lt;soap:address location=&#8221;http://www.ignyte.com/webservices/</span><br style="FONT-WEIGHT: bold" /><span style="FONT-WEIGHT: bold">ignyte.whatsshowing.webservice/moviefunctions.asmx&#8221; /&gt;</span><br />
&lt;/wsdl:port&gt;<br />
&lt;wsdl:port name=&#8221;MovieInformationSoap12&#8243; binding=<br />
&#8220;tns:MovieInformationSoap12&#8243;&gt;<br />
<span style="FONT-WEIGHT: bold">&lt;soap12:address location=&#8221;http://www.ignyte.com/webservices/</span><br style="FONT-WEIGHT: bold" /><span style="FONT-WEIGHT: bold">ignyte.whatsshowing.webservice/moviefunctions.asmx&#8221; /&gt;</span><br />
&lt;/wsdl:port&gt;<br />
&lt;/wsdl:service&gt;</p>
<p>We will now look at how to generate the web service client code for the Movie information web service.</p>
<p><strong>Building and running the Java web service clients</strong></p>
<p>The source code and build files for the example are available in the <em>wsdl2Java</em> folder of the downloaded source code. We will follow the steps below to build and execute the web service client:</p>
<ul>
<li>Generate the web service clients</li>
<li>Analyze the generated artifacts</li>
<li>Modify the generated code</li>
<li>Build the web service client</li>
<li>Run the web service client</li>
</ul>
<p><strong>Generate the web service clients</strong></p>
<p>We will use the Ant build script (<em>build.xml</em>) for generating the web service client code and building the project code as shown below. Navigate to the <em>wsdl2java</em> folder of the downloaded source code. Execute the <em>cxfWSDLToJava</em> target by navigating to the <em>wsdl2java</em> folder and running the following command:</p>
<pre style="MARGIN-LEFT: 40px"><span style="FONT-WEIGHT: bold">ant cxfWSDLToJava</span></pre>
<p>The following figure shows the output generated upon running the ant command:</p>
<p>The <em>cxfWSDLToJava</em> ant target calls the CXF tool <em>apache.cxf.tools.wsdlto.WSDLToJava</em> to generate web service client code based on the URL <a href="http://www.ignyte.com/webservices/ignyte.whatsshowing.webservice/moviefunctions.asmx?wsdl" target="blank">http://www.ignyte.com/webservices/ignyte.whatsshowing.webservice/moviefunctions.asmx?wsdl</a></p>
<p>The following is a code snippet of ant target cxfWSDLToJava in build.xml:</p>
<pre style="MARGIN-LEFT: 40px">&lt;target name="cxfWSDLToJava"&gt;
  &lt;java classname="org.apache.cxf.tools.wsdlto.WSDLToJava"
  fork="true"&gt;
    &lt;arg value="-client"/&gt;
    &lt;arg value="-d"/&gt;
    &lt;arg value="src"/&gt;
    &lt;arg value="http://www.ignyte.com/webservices/ignyte.
    whatsshowing.webservice/moviefunctions.asmx?wsdl"/&gt;
    &lt;classpath&gt;
      &lt;path refid="cxf.classpath"/&gt;
    &lt;/classpath&gt;
  &lt;/java&gt;
&lt;/target&gt;</pre>
<p><em>WSDLToJava</em> generates JAX-WS compliant Java code for the services defined in the WSDL document. Based on the parameters passed, it can generate the starting point of the code for developing the web service client and service. The <em>client</em> option, as shown in above snippet, generates the client code. The know about more about the options supported by the <em>WSDLToJava</em> tool , refer to CXF website—<a href="http://cwiki.apache.org/CXF20DOC/wsdl-to-java.html" target="blank">http://cwiki.apache.org/CXF20DOC/wsdl-to-java.html</a></p>
<p>After executing the command, the generated code is created in the <em>wsdl2java/src</em> folder.</p>
<p><strong>Analyzing the JAX-WS and client generated artifacts</strong></p>
<p>The following artifacts are generated in the <em>wsdl2Java/src/com/ignite/whatsshowing</em> folder:</p>
<ul>
<li>JAXB classes— these are generated by reading the schema definitions defined in the Movie information WSDL. The classes generated for the Movie information web service are <em>ArrayOfMovie</em>, <em>ArrayOfTheater</em>, <em>ArrayOfUpcomingMovie</em>, <em>Movie</em>, <em>Theater UpcomingMovie</em>, and <em>ObjectFactory</em>.</li>
<li>The <em>RequestWrapper</em> and <em>ResponseWrapper</em> classes—as the Movie information web service uses the document-literal web service style, the <em>Request</em> and <em>Response</em> wrapper objects are generated for input and output message formats for the operations GetTheatersAndMovies and <em>GetUpcomingMovies</em>. The <em>Request</em> and <em>Response</em> Wrapper objects wrap the input and output for document-literal wrapped style web services. The <em>GetTheatersAndMovies</em> (Request Wrapper) and <em>GetTheatersAndMoviesResponse</em> (Response Wrapper) are generated for the <em>getTheatersAndMovies</em> operation.</li>
<li>The next code snippet shows the generated <em>GetTheatersAndMovies.java</em>. As you can see below, the class has JAXB annotations that are defined to map Java to an XML element. The <em>@XmlRootElement</em> defines the root element of the input request which has the name <em>GetTheatersAndMovies</em>. The attributes <em>zipCode</em> and <em>radius</em> are contained in the <em>GetTheatersAndMovies</em> XML element. The annotations are used to map Java to an XML request.</li>
</ul>
<p style="PADDING-LEFT: 60px">@XmlAccessorType(XmlAccessType.FIELD)<br />
@XmlType(name = &#8220;&#8221;, propOrder = {<br />
&#8220;month&#8221;,<br />
&#8220;year&#8221;<br />
})<br />
@XmlRootElement(name = &#8220;GetTheatersAndMovies&#8221;)<br />
public class GetTheatersAndMovies {<br />
protected String zipCode;<br />
protected int radius;<br />
public String getZipCode() {<br />
return zipCode;<br />
}<br />
public void setZipCode(String value) {<br />
this.zipCode = value;<br />
}<br />
public int getRadius() {<br />
return radius;<br />
}<br />
public void setRadius(int value) {<br />
this.radius = value;<br />
}<br />
}</p>
<ul>
<li>Service Interface: This class contains the service interface for the Movie information web service. The service interface generated for Movie information web service is MovieInformationSoap.java</li>
<li>Service class—this is the class that web service clients will use to make requests to the web service. The service class generated for the Movie information web service is <em>MovieInformation.java</em>. The service class contains the <em>@WebServiceClient</em> annotation and lookup methods to retrieve the Service Interface.</li>
<li>Client code— the standalone web service client code that provides a starting point for the client code, which calls various operations of the web service. You need to modify the client code to provide the input for each of the operations being invoked. The client code generated for the Movie information web service is <em>MovieInformationSoap_MovieInformationSoap12_Client.java</em> and <em>MovieInformationSoap_MovieInformationSoap_Client.java</em>. Two client codes are generated as there are two ports defined for the Movie information service, <em>MovieInformationSoap</em> and <em>MovieInformationSoap12</em>. You can use any of the client code. There are two port types provided to support SOAP 1.1 and SOAP 1.2 request.</li>
</ul>
<p><strong>Modifying the generated client</strong></p>
<p>We will now modify the generated client <em>MovieInformationSoap_MovieInformationSoap12_Client.java</em> to provide input to the <em>getTheatersAndMovies</em> operations method. Open the <em>MovieInformationSoap_MovieInformationSoap12_Client.java</em> in any text editor, and modify the generated code, as highlighted in bold.</p>
<pre style="MARGIN-LEFT: 40px">package com.ignyte.whatsshowing;
import java.io.File;
//Other imports…..
<span style="FONT-WEIGHT: bold">import java.util.List;</span>
public final class MovieInformationSoap_MovieInformationSoap12_Client
{
  public static void main(String args[]) throws Exception {
    //Refer to generated code for compete listing
    System.out.println("Invoking getTheatersAndMovies...");
    <span style="FONT-WEIGHT: bold">java.lang.String _getTheatersAndMovies_zipCode = "78750";</span><br style="FONT-WEIGHT: bold" /><span style="FONT-WEIGHT: bold">    int _getTheatersAndMovies_radius = 2;</span>
com.ignyte.whatsshowing.ArrayOfTheater _getTheatersAndMovies__
return = port.getTheatersAndMovies(_getTheatersAndMovies_zipCode, _
getTheatersAndMovies_radius);
System.out.println("getTheatersAndMovies.result=" + _
getTheatersAndMovies__return);
  <span style="FONT-WEIGHT: bold">System.out.println("Theater List is : "</span><br style="FONT-WEIGHT: bold" /><span style="FONT-WEIGHT: bold">    + _getTheatersAndMovies__return.getTheater().size());</span><br style="FONT-WEIGHT: bold" /><span style="FONT-WEIGHT: bold">List&lt;Theater&gt; theatreList = _getTheatersAndMovies__return.</span><br style="FONT-WEIGHT: bold" /><span style="FONT-WEIGHT: bold">getTheater();</span><br style="FONT-WEIGHT: bold" /><span style="FONT-WEIGHT: bold">  for (int i = 0; i &lt; theatreList.size(); i++) {</span><br style="FONT-WEIGHT: bold" /><span style="FONT-WEIGHT: bold">    System.out.println("Theatre Name : " +</span><br style="FONT-WEIGHT: bold" /><span style="FONT-WEIGHT: bold">    theatreList.get(i).getName());</span><br style="FONT-WEIGHT: bold" /><span style="FONT-WEIGHT: bold">    List&lt;Movie&gt; movieList =</span><br style="FONT-WEIGHT: bold" /><span style="FONT-WEIGHT: bold">    theatreList.get(i).getMovies().getMovie();</span><br style="FONT-WEIGHT: bold" /><span style="FONT-WEIGHT: bold">      for (int j = 0; j &lt; movieList.size(); j++) {</span><br style="FONT-WEIGHT: bold" /><span style="FONT-WEIGHT: bold">    System.out.println("Movie Name : " +</span><br style="FONT-WEIGHT: bold" /><span style="FONT-WEIGHT: bold">          movieList.get(j).getName());</span><br style="FONT-WEIGHT: bold" /><span style="FONT-WEIGHT: bold">    System.out.println("Movie Rating : " +</span><br style="FONT-WEIGHT: bold" /><span style="FONT-WEIGHT: bold">    movieList.get(j).getRating());</span><br style="FONT-WEIGHT: bold" /><span style="FONT-WEIGHT: bold">    }</span><br style="FONT-WEIGHT: bold" /><span style="FONT-WEIGHT: bold">    System.out.println("End of Movies for Theatre :"</span><br style="FONT-WEIGHT: bold" /><span style="FONT-WEIGHT: bold">    + theatreList.get(i).getName());</span><br style="FONT-WEIGHT: bold" /><span style="FONT-WEIGHT: bold">  }</span>
//Remaining code block</pre>
<p>As you can see in the previous code, we specify the zip code as <em>78750</em> and radius as <em>2</em>. Next, the operation <em>getTheatersAndMovies(_getTheatersAndMovies_zipCode</em>, <em>_getTheatersAndMovies_radius)</em> is invoked. The operation returns the <em>com.ignyte.whatsshowing.ArrayOfTheater</em> response. We then get the list of theatres from <em>com.ignyte.whatsshowing.ArrayOfTheater</em> object by calling the <em>_getTheatersAndMovies__return.getTheater()</em> method. Next we iterate through the <em>theatreList</em> and print the name, <em>theatreList.get(i).getName()</em>. For each theatre, we retrieve the list of movies running in that theatre, by calling <em>theatreList.get(i).getMovies().getMovie()</em>. We then iterate through the set of movies and print the name, <em>movieList.get(j).getName()</em> and rating, <em>movieList.get(j).getRating()</em> for each movie.</p>
<p><strong>Building the client</strong></p>
<p>To build the client, navigate to the <em>wsld2java</em> folder, and run the following command to build the code:</p>
<pre style="MARGIN-LEFT: 40px"><span style="FONT-WEIGHT: bold">ant build</span></pre>
<p>The following screenshot shows the output generated on running the <em>ant</em> command:</p>
<p><img class="alignnone size-full wp-image-104" title="CXFWsdl2Java Build" src="http://cxf.soaweb.co.in/wp-content/uploads/2010/01/5401_08_04.png" alt="CXFWsdl2Java Build" width="647" height="215" /></p>
<p><strong>Running the client</strong></p>
<p>To run the client, navigate to the <em>wsld2java</em> folder, and run the following command to build the code:</p>
<pre style="MARGIN-LEFT: 40px"><span style="FONT-WEIGHT: bold">ant runClient</span></pre>
<p>This command calls the target <em>runClient</em> in <em>build.xml</em>, and executes the <em>MovieInformationSoap_MovieInformationSoap_Client</em> class.</p>
<p>The following output will be printed on the console. Look for the <strong>Theater List</strong> is system output message to determine how many theatres are retrieved for that area code. For each theatre you see the movie information being printed on the console. Look for the <strong>Movie Name</strong> and <strong>Movie Rating</strong> system output message, as shown in the next screenshot. Note that this</p>
<p><img class="alignnone size-full wp-image-103" title="CXF WSDL2Java Output" src="http://cxf.soaweb.co.in/wp-content/uploads/2010/01/5401_08_05.png" alt="CXF WSDL2Java Output" width="668" height="415" /></p>
<p>We have thus successfully invoked the Movie information web service.</p>
<p><strong>Summary</strong></p>
<p>In this blog , we looked at how to:</p>
<ul>
<li>Utilize CXF tools for web services development</li>
<li>Create Java web service clients from WSDL and invoke real world web services</li>
</ul>
<p>To know, more about how to develop SOAP and RESTful web services, get a copy of the Apache CXF Web Service Book -</p>
<p><a href="http://www.packtpub.com/apache-cxf-web-service-development/mid/2312092oq0d7?utm_source=cxf.soaweb.co.in&amp;utm_medium=affiliate&amp;utm_content=authorsite&amp;utm_campaign=mdb_001927" target="_blank"><div class="amzshcs" id="amzshcs-0ffe1990b5c22a8e10d5ec748e774099"><div class="amzshcs-item" id="amzshcs-item-b8543e78f0aeb0dd818a17e03e0b28ed"> <a href="http://www.amazon.com/Apache-CXF-Web-Service-Development/dp/1847195407%3FSubscriptionId%3DAKIAJWQLRXGXNE5KBGJA%26tag%3Dsw0fd-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D1847195407"><img src="http://ecx.images-amazon.com/images/I/51Sstnuk-CL._SL160_.jpg" height="160" width="130" alt="Image of Apache CXF Web Service Development" title="Apache CXF Web Service Development" /></a> </div></div> </a></p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Invoking+.NET+Web+Service+using+CXF+Apache+WSDL2Java+Tool+http://cxf.soaweb.co.in/?p=99" title="Post to Twitter"><img class="nothumb" src="http://cxf.soaweb.co.in/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Invoking+.NET+Web+Service+using+CXF+Apache+WSDL2Java+Tool+http://cxf.soaweb.co.in/?p=99" title="Post to Twitter">Tweet This Post</a> <a class="tt" href="http://delicious.com/post?url=http://cxf.soaweb.co.in/index.php/2010/01/16/invoking-net-web-service-using-cxf-apache-wsdl2java-tool/&amp;title=Invoking+.NET+Web+Service+using+CXF+Apache+WSDL2Java+Tool" title="Post to Delicious"><img class="nothumb" src="http://cxf.soaweb.co.in/wp-content/plugins/tweet-this/icons/tt-delicious.png" alt="Post to Delicious" /></a> <a class="tt" href="http://delicious.com/post?url=http://cxf.soaweb.co.in/index.php/2010/01/16/invoking-net-web-service-using-cxf-apache-wsdl2java-tool/&amp;title=Invoking+.NET+Web+Service+using+CXF+Apache+WSDL2Java+Tool" title="Post to Delicious">Delicious</a> <a class="tt" href="http://digg.com/submit?url=http://cxf.soaweb.co.in/index.php/2010/01/16/invoking-net-web-service-using-cxf-apache-wsdl2java-tool/&amp;title=Invoking+.NET+Web+Service+using+CXF+Apache+WSDL2Java+Tool" title="Post to Digg"><img class="nothumb" src="http://cxf.soaweb.co.in/wp-content/plugins/tweet-this/icons/tt-digg.png" alt="Post to Digg" /></a> <a class="tt" href="http://digg.com/submit?url=http://cxf.soaweb.co.in/index.php/2010/01/16/invoking-net-web-service-using-cxf-apache-wsdl2java-tool/&amp;title=Invoking+.NET+Web+Service+using+CXF+Apache+WSDL2Java+Tool" title="Post to Digg">Digg This Post</a></p>]]></content:encoded>
			<wfw:commentRss>http://cxf.soaweb.co.in/index.php/2010/01/16/invoking-net-web-service-using-cxf-apache-wsdl2java-tool/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sample chapter for Apache CXF Web Service Book</title>
		<link>http://cxf.soaweb.co.in/index.php/2010/01/10/sample-chapter-for-apache-cxf-web-service-book/</link>
		<comments>http://cxf.soaweb.co.in/index.php/2010/01/10/sample-chapter-for-apache-cxf-web-service-book/#comments</comments>
		<pubDate>Sun, 10 Jan 2010 07:08:28 +0000</pubDate>
		<dc:creator>Naveen</dc:creator>
				<category><![CDATA[CXF Services Book]]></category>
		<category><![CDATA[cxf sample chapter]]></category>

		<guid isPermaLink="false">http://cxf.soaweb.co.in/?p=95</guid>
		<description><![CDATA[I am happy to share with you the preface and sample chapter for Apache CXF Web Service Book.  Comments welcome
  
// 


 Tweet This Post  Delicious  Digg This Post]]></description>
			<content:encoded><![CDATA[<p>I am happy to share with you the preface and sample chapter for Apache CXF Web Service Book.  Comments welcome.<a class="downloadlink" href="http://cxf.soaweb.co.in/wp-content/plugins/download-monitor/download.php?id=2" title="Version 1.0 downloaded 291 times" >Sample Apache CXF Web Service Book Chapter</a></p>
<p><div class="amzshcs" id="amzshcs-0ffe1990b5c22a8e10d5ec748e774099"><div class="amzshcs-item" id="amzshcs-item-b8543e78f0aeb0dd818a17e03e0b28ed"> <a href="http://www.amazon.com/Apache-CXF-Web-Service-Development/dp/1847195407%3FSubscriptionId%3DAKIAJWQLRXGXNE5KBGJA%26tag%3Dsw0fd-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D1847195407"><img src="http://ecx.images-amazon.com/images/I/51Sstnuk-CL._SL160_.jpg" height="160" width="130" alt="Image of Apache CXF Web Service Development" title="Apache CXF Web Service Development" /></a> </div></div></p>
<p><script type="text/javascript">// <![CDATA[
   google_ad_client = "pub-3843887054708077"; /* 468x15, created 6/2/10 */ google_ad_slot = "8275571625"; google_ad_width = 468; google_ad_height = 15;
// ]]&gt;</script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script></p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Sample+chapter+for+Apache+CXF+Web+Service+Book+http://cxf.soaweb.co.in/?p=95" title="Post to Twitter"><img class="nothumb" src="http://cxf.soaweb.co.in/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Sample+chapter+for+Apache+CXF+Web+Service+Book+http://cxf.soaweb.co.in/?p=95" title="Post to Twitter">Tweet This Post</a> <a class="tt" href="http://delicious.com/post?url=http://cxf.soaweb.co.in/index.php/2010/01/10/sample-chapter-for-apache-cxf-web-service-book/&amp;title=Sample+chapter+for+Apache+CXF+Web+Service+Book" title="Post to Delicious"><img class="nothumb" src="http://cxf.soaweb.co.in/wp-content/plugins/tweet-this/icons/tt-delicious.png" alt="Post to Delicious" /></a> <a class="tt" href="http://delicious.com/post?url=http://cxf.soaweb.co.in/index.php/2010/01/10/sample-chapter-for-apache-cxf-web-service-book/&amp;title=Sample+chapter+for+Apache+CXF+Web+Service+Book" title="Post to Delicious">Delicious</a> <a class="tt" href="http://digg.com/submit?url=http://cxf.soaweb.co.in/index.php/2010/01/10/sample-chapter-for-apache-cxf-web-service-book/&amp;title=Sample+chapter+for+Apache+CXF+Web+Service+Book" title="Post to Digg"><img class="nothumb" src="http://cxf.soaweb.co.in/wp-content/plugins/tweet-this/icons/tt-digg.png" alt="Post to Digg" /></a> <a class="tt" href="http://digg.com/submit?url=http://cxf.soaweb.co.in/index.php/2010/01/10/sample-chapter-for-apache-cxf-web-service-book/&amp;title=Sample+chapter+for+Apache+CXF+Web+Service+Book" title="Post to Digg">Digg This Post</a></p>]]></content:encoded>
			<wfw:commentRss>http://cxf.soaweb.co.in/index.php/2010/01/10/sample-chapter-for-apache-cxf-web-service-book/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apache CXF Web Service Book TOC</title>
		<link>http://cxf.soaweb.co.in/index.php/2009/12/29/apache-cxf-web-service-book-toc/</link>
		<comments>http://cxf.soaweb.co.in/index.php/2009/12/29/apache-cxf-web-service-book-toc/#comments</comments>
		<pubDate>Tue, 29 Dec 2009 13:09:14 +0000</pubDate>
		<dc:creator>Naveen</dc:creator>
				<category><![CDATA[CXF Services Book]]></category>
		<category><![CDATA[Apache CXF BOOK TOC]]></category>

		<guid isPermaLink="false">http://cxf.soaweb.co.in/?p=69</guid>
		<description><![CDATA[To know more about the contents of the Apache CXF Web Service book, download the TOC -
  
 Tweet This Post  Delicious  Digg This Post]]></description>
			<content:encoded><![CDATA[<p>To know more about the contents of the Apache CXF Web Service book, download the TOC -<br />
<a class="downloadlink" href="http://cxf.soaweb.co.in/wp-content/plugins/download-monitor/download.php?id=1" title="Version 1.0 downloaded 181 times" >Apache Web Service TOC Book</a></p>
<p><div class="amzshcs" id="amzshcs-0ffe1990b5c22a8e10d5ec748e774099"><div class="amzshcs-item" id="amzshcs-item-b8543e78f0aeb0dd818a17e03e0b28ed"> <a href="http://www.amazon.com/Apache-CXF-Web-Service-Development/dp/1847195407%3FSubscriptionId%3DAKIAJWQLRXGXNE5KBGJA%26tag%3Dsw0fd-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D1847195407"><img src="http://ecx.images-amazon.com/images/I/51Sstnuk-CL._SL160_.jpg" height="160" width="130" alt="Image of Apache CXF Web Service Development" title="Apache CXF Web Service Development" /></a> </div></div></p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Apache+CXF+Web+Service+Book+TOC+http://cxf.soaweb.co.in/?p=69" title="Post to Twitter"><img class="nothumb" src="http://cxf.soaweb.co.in/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Apache+CXF+Web+Service+Book+TOC+http://cxf.soaweb.co.in/?p=69" title="Post to Twitter">Tweet This Post</a> <a class="tt" href="http://delicious.com/post?url=http://cxf.soaweb.co.in/index.php/2009/12/29/apache-cxf-web-service-book-toc/&amp;title=Apache+CXF+Web+Service+Book+TOC" title="Post to Delicious"><img class="nothumb" src="http://cxf.soaweb.co.in/wp-content/plugins/tweet-this/icons/tt-delicious.png" alt="Post to Delicious" /></a> <a class="tt" href="http://delicious.com/post?url=http://cxf.soaweb.co.in/index.php/2009/12/29/apache-cxf-web-service-book-toc/&amp;title=Apache+CXF+Web+Service+Book+TOC" title="Post to Delicious">Delicious</a> <a class="tt" href="http://digg.com/submit?url=http://cxf.soaweb.co.in/index.php/2009/12/29/apache-cxf-web-service-book-toc/&amp;title=Apache+CXF+Web+Service+Book+TOC" title="Post to Digg"><img class="nothumb" src="http://cxf.soaweb.co.in/wp-content/plugins/tweet-this/icons/tt-digg.png" alt="Post to Digg" /></a> <a class="tt" href="http://digg.com/submit?url=http://cxf.soaweb.co.in/index.php/2009/12/29/apache-cxf-web-service-book-toc/&amp;title=Apache+CXF+Web+Service+Book+TOC" title="Post to Digg">Digg This Post</a></p>]]></content:encoded>
			<wfw:commentRss>http://cxf.soaweb.co.in/index.php/2009/12/29/apache-cxf-web-service-book-toc/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Apache CXF Web Service Book Contents Overview</title>
		<link>http://cxf.soaweb.co.in/index.php/2009/12/29/cxf-book-contents-overview/</link>
		<comments>http://cxf.soaweb.co.in/index.php/2009/12/29/cxf-book-contents-overview/#comments</comments>
		<pubDate>Tue, 29 Dec 2009 12:22:07 +0000</pubDate>
		<dc:creator>Naveen</dc:creator>
				<category><![CDATA[CXF Services Book]]></category>
		<category><![CDATA[cxf sample chapter]]></category>

		<guid isPermaLink="false">http://cxf.soaweb.co.in/?p=63</guid>
		<description><![CDATA[Here is the preface for the CXF Web Service book.
Chapter 1: Getting Familiar with CXF revisits web service concepts and provides an introduction to CXF framework and its usage, and prepares the CXF environment for the following chapters.
By the end of this chapter the reader will be able to understand the core concepts of CXF.
Chapter [...]]]></description>
			<content:encoded><![CDATA[<p>Here is the preface for the CXF Web Service book.</p>
<p><strong>Chapter 1: </strong><em><strong>Getting Familiar with CXF</strong> </em>revisits web service concepts and provides an introduction to CXF framework and its usage, and prepares the CXF environment for the following chapters.</p>
<blockquote><p>By the end of this chapter the reader will be able to understand the core concepts of CXF.</p></blockquote>
<p><strong>Chapter 2: </strong><em><strong>Developing a Web Service with CXF</strong> </em>focuses on getting the reader quickly started with the CXF framework by developing a simple web service and running it under the Tomcat container. Chapter 2 would also provide details on CXF architecture.</p>
<blockquote><p>By the end of this chapter the reader will be able to develop a simple web service using CXF.</p></blockquote>
<p><strong> Chapter 3: </strong><em><strong>Working with CXF Frontends</strong> </em>illustrates the use of different frontends, like JAX-WS and CXF simple fronted API, and shows how to apply code-first and contract first development approaches for developing web services. We will look at how to create dynamic web service clients, the use of web service context, and how to work directly with XML messages using CXF Provider and Dispatch implementation.</p>
<blockquote><p>By the end of this chapter the reader will be able to apply different frontends to develop a web service.</p></blockquote>
<p><strong>Chapter 4: </strong><em><strong>Learning about Service Transports</strong> </em>explains basic transport protocols for a service and shows you how to configure HTTP, HTTP(s), JMS, and Local protocol for web services communication. You will get introduced to the concept of HTTP conduit, which enables the client program to apply policies or properties to HTTP and HTTPs protocols, and how to generate a crypto key and a key store for HTTPs based service communication. You will learn how to use JMS protocol for web services communication and how to facilitate web services message exchange using CXF Local service transport.</p>
<blockquote><p>By the end of this chapter the reader will be able develop services with different transports</p></blockquote>
<p><strong>Chapter 5: </strong><em><strong>Implementing Advanced Features</strong> </em>will explain advanced concepts using CXF Features, Interceptors, and Invokers, and how to integrate these concepts in existing applications.</p>
<blockquote><p>By the end of this chapter the reader will be able develop services with features like Interceptors and Invokers</p></blockquote>
<p><strong>Chapter 6: </strong><em><strong>Developing RESTful Services with CXF</strong> </em>explains the concept of REST technology and JAX-RS specifications, how CXF realizes the JAX-RS specification, and demonstrates additional features for developing enterprise RESTful services. We will look at how to design, develop, and unit test the RESTful Service by taking a real world example using CXF JAX-RS implementation.</p>
<blockquote><p>By the end of this chapter the reader will be able to design, develop, and unit test the RESTful service</p></blockquote>
<p><strong> Chapter 7: </strong><em><strong>Deploying RESTful Services with CXF</strong> </em>will explain how to deploy REST services in a container like Tomcat using Spring configuration, and how to test out the various operations exposed by the RESTFul application using CXF RESTful client API and using a web service development tool. We will look at how to enable exception handling, JSON message support, and logging support for RESTful applications using CXF framework.</p>
<blockquote><p>By the end of this chapter the reader would be able utilize various CXF features for developing RESTful services and how to leverage Spring configuration for deploying RESTful service in the tomcat container.</p></blockquote>
<p><strong>Chapter 8: </strong><em><strong>Working with CXF Tools</strong> </em>will explain some of the commonly used CXF tools that assist us in web services development. We will look at how to invoke a real world .NET service over the internet using a Java client and JavaScript, create web service implementation from WSDL files, generate WSDL files from web service implementation, and validate the WSDL file for compliance.</p>
<blockquote><p>By the end of this chapter the reader will be able to use different CXF tools to develop a service.</p></blockquote>
<p><em><strong> </strong></em><em><strong>Appendix A</strong> </em>deals with how to set up the CXF environment, provides details on how the source code for each chapter is organized, and shows how to run the source code examples using the ANT tool and Maven Tool.</p>
<p><em> </em><em><strong>Appendix B</strong> </em>provides an explanation of the basics of the Spring framework and IoC concepts, along with an end-to-end example which utilizes Spring IoC concepts.</p>
<p style="padding-left: 30px;">By the end of this Appendix chapter the reader will have a good understanding of Spring capabilities used in the context of CXF web   services development in this book.</p>
<p style="text-align: left;"><div class="amzshcs" id="amzshcs-0ffe1990b5c22a8e10d5ec748e774099"><div class="amzshcs-item" id="amzshcs-item-b8543e78f0aeb0dd818a17e03e0b28ed"> <a href="http://www.amazon.com/Apache-CXF-Web-Service-Development/dp/1847195407%3FSubscriptionId%3DAKIAJWQLRXGXNE5KBGJA%26tag%3Dsw0fd-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D1847195407"><img src="http://ecx.images-amazon.com/images/I/51Sstnuk-CL._SL160_.jpg" height="160" width="130" alt="Image of Apache CXF Web Service Development" title="Apache CXF Web Service Development" /></a> </div></div></p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Apache+CXF+Web+Service+Book+Contents+Overview+http://cxf.soaweb.co.in/?p=63" title="Post to Twitter"><img class="nothumb" src="http://cxf.soaweb.co.in/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Apache+CXF+Web+Service+Book+Contents+Overview+http://cxf.soaweb.co.in/?p=63" title="Post to Twitter">Tweet This Post</a> <a class="tt" href="http://delicious.com/post?url=http://cxf.soaweb.co.in/index.php/2009/12/29/cxf-book-contents-overview/&amp;title=Apache+CXF+Web+Service+Book+Contents+Overview" title="Post to Delicious"><img class="nothumb" src="http://cxf.soaweb.co.in/wp-content/plugins/tweet-this/icons/tt-delicious.png" alt="Post to Delicious" /></a> <a class="tt" href="http://delicious.com/post?url=http://cxf.soaweb.co.in/index.php/2009/12/29/cxf-book-contents-overview/&amp;title=Apache+CXF+Web+Service+Book+Contents+Overview" title="Post to Delicious">Delicious</a> <a class="tt" href="http://digg.com/submit?url=http://cxf.soaweb.co.in/index.php/2009/12/29/cxf-book-contents-overview/&amp;title=Apache+CXF+Web+Service+Book+Contents+Overview" title="Post to Digg"><img class="nothumb" src="http://cxf.soaweb.co.in/wp-content/plugins/tweet-this/icons/tt-digg.png" alt="Post to Digg" /></a> <a class="tt" href="http://digg.com/submit?url=http://cxf.soaweb.co.in/index.php/2009/12/29/cxf-book-contents-overview/&amp;title=Apache+CXF+Web+Service+Book+Contents+Overview" title="Post to Digg">Digg This Post</a></p>]]></content:encoded>
			<wfw:commentRss>http://cxf.soaweb.co.in/index.php/2009/12/29/cxf-book-contents-overview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apache CXF Web Service Book Released</title>
		<link>http://cxf.soaweb.co.in/index.php/2009/12/19/cxf-service-book-released/</link>
		<comments>http://cxf.soaweb.co.in/index.php/2009/12/19/cxf-service-book-released/#comments</comments>
		<pubDate>Sat, 19 Dec 2009 08:58:18 +0000</pubDate>
		<dc:creator>Naveen</dc:creator>
				<category><![CDATA[CXF Services Book]]></category>
		<category><![CDATA[apache cxf]]></category>
		<category><![CDATA[apache cxf web service book]]></category>
		<category><![CDATA[book]]></category>
		<category><![CDATA[CXF]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://cxf.soaweb.co.in/?p=48</guid>
		<description><![CDATA[I am glad to inform that our book on CXF service development has been released and now available for purchase from PACKT site. This is the first practical guide on Apache CXF services development.
This book is for developers who want to design and develop SOAP and RESTful services using Apache CXF framework and leverage various CXF features [...]]]></description>
			<content:encoded><![CDATA[<p>I am glad to inform that our book on CXF service development has been released and now available for purchase from <a href="http://www.packtpub.com/apache-cxf-web-service-development/mid/2312092oq0d7?utm_source=cxf.soaweb.co.in&amp;utm_medium=affiliate&amp;utm_content=authorsite&amp;utm_campaign=mdb_001927" target="_blank">PACKT site</a>. This is the first practical guide on Apache CXF services development.</p>
<p>This book is for developers who want to design and develop SOAP and RESTful services using Apache CXF framework and leverage various CXF features for service development. It is ideal for developers who have some experience in Java application development as well as some basic knowledge of web services, but it covers some of the basic fundamentals of web services and REST to get you acquainted with these technologies before using these concepts to develop services using the CXF framework. As part of Appendix, it also has a dedicated Chapter on Spring framework, to get the readers acquainted with the Spring capabilities used in the context of CXF web services development for this book.</p>
<p>We would love to hear any feedbacks on the book. If you find any errata or suggestions for the book, please post it in our forums.</p>
<p><script type="text/javascript">// <![CDATA[
   google_ad_client = "pub-3843887054708077"; /* 468x15, created 6/2/10 */ google_ad_slot = "8275571625"; google_ad_width = 468; google_ad_height = 15;
// ]]&gt;</script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script></p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Apache+CXF+Web+Service+Book+Released+http://cxf.soaweb.co.in/?p=48" title="Post to Twitter"><img class="nothumb" src="http://cxf.soaweb.co.in/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Apache+CXF+Web+Service+Book+Released+http://cxf.soaweb.co.in/?p=48" title="Post to Twitter">Tweet This Post</a> <a class="tt" href="http://delicious.com/post?url=http://cxf.soaweb.co.in/index.php/2009/12/19/cxf-service-book-released/&amp;title=Apache+CXF+Web+Service+Book+Released" title="Post to Delicious"><img class="nothumb" src="http://cxf.soaweb.co.in/wp-content/plugins/tweet-this/icons/tt-delicious.png" alt="Post to Delicious" /></a> <a class="tt" href="http://delicious.com/post?url=http://cxf.soaweb.co.in/index.php/2009/12/19/cxf-service-book-released/&amp;title=Apache+CXF+Web+Service+Book+Released" title="Post to Delicious">Delicious</a> <a class="tt" href="http://digg.com/submit?url=http://cxf.soaweb.co.in/index.php/2009/12/19/cxf-service-book-released/&amp;title=Apache+CXF+Web+Service+Book+Released" title="Post to Digg"><img class="nothumb" src="http://cxf.soaweb.co.in/wp-content/plugins/tweet-this/icons/tt-digg.png" alt="Post to Digg" /></a> <a class="tt" href="http://digg.com/submit?url=http://cxf.soaweb.co.in/index.php/2009/12/19/cxf-service-book-released/&amp;title=Apache+CXF+Web+Service+Book+Released" title="Post to Digg">Digg This Post</a></p>]]></content:encoded>
			<wfw:commentRss>http://cxf.soaweb.co.in/index.php/2009/12/19/cxf-service-book-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
