<?xml version="1.0" encoding="UTF-8" standalone="no"?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:gd="http://schemas.google.com/g/2005" xmlns:georss="http://www.georss.org/georss" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:thr="http://purl.org/syndication/thread/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-7164483852868486084</atom:id><lastBuildDate>Thu, 24 Oct 2024 15:34:42 +0000</lastBuildDate><category>Technical</category><category>Hibernate</category><category>Spring</category><category>web services</category><title>Chintan Parekh's Blog</title><description>Here you will find blogs on my regular technical explorations, some recent happenings. and few of my hobbies....

Any Feedback from anyone..most welcome :)</description><link>http://chintanpparekh.blogspot.com/</link><managingEditor>noreply@blogger.com (Chintan Parekh)</managingEditor><generator>Blogger</generator><openSearch:totalResults>3</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><language>en-us</language><itunes:explicit>no</itunes:explicit><itunes:summary>Here you will find blogs on my regular technical explorations, some recent happenings. and few of my hobbies.... Any Feedback from anyone..most welcome :)</itunes:summary><itunes:subtitle>Here you will find blogs on my regular technical explorations, some recent happenings. and few of my hobbies.... Any Feedback from anyone..most welcome :)</itunes:subtitle><itunes:owner><itunes:email>noreply@blogger.com</itunes:email></itunes:owner><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7164483852868486084.post-855133075250331572</guid><pubDate>Thu, 10 Dec 2009 03:45:00 +0000</pubDate><atom:updated>2009-12-13T19:58:11.821+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Technical</category><category domain="http://www.blogger.com/atom/ns#">web services</category><title>Develop simple JAX-WS web service using Metro</title><description>&lt;p&gt;After working on JAX-RPC web services, it is time to go for much acclaimed web services technology &lt;strong&gt;JAX-WS&lt;/strong&gt;. People says it is an extension of JAX-RPC, some says it’s a replacement of JAX-RPC. &lt;/p&gt;  &lt;p&gt;Let me brief you about some difference between JAX-RPC and JAX-WS before we jump to jax-ws service.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;JAX-WS maps to Java 5. So features of Java 5 are supported like annotations, generics, etc. &lt;/li&gt;    &lt;li&gt;Support SOAP 1.1 and 1.2 &lt;/li&gt;    &lt;li&gt;support WS-I basic profile 1.1 (new version) &lt;/li&gt;    &lt;li&gt;JAX-RPC has it’s own data type mapping model and covering 90% of XML schemas. However I have experienced interoperability issue while using JAX-RPC. JAX-WS uses JAXB mapping model which covers all XML Schemas with less interoperability issues. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Detailed features list/comparison is available on &lt;a href="http://www.ibm.com/developerworks/webservices/library/ws-tip-jaxwsrpc.html"&gt;http://www.ibm.com/developerworks/webservices/library/ws-tip-jaxwsrpc.html&lt;/a&gt; (worth reading!!!!)&lt;/p&gt;  &lt;p&gt;Discussing my own experience, Recently I have been involved in assignment where we had to replace existing AXIS services with JAX-WS services. When we started, we were not sure about success because our applications were first one who stared this remediation. I remember we haven’t had any major hitch (like Interoperability) in remediation task. These services have different types of consumers like .NET application, J2EE application, Workflow Tool. Moreover many of these services were using standard java types like HashTable, Map (either as a input parameter or return type) and luckily we did not face any issue during remediation. All these consumers are able to access new service without any issue. :). &lt;/p&gt;  &lt;p&gt;Now let’s start with JAX-WS web services. We all know that services can be developed either using Top-down approach(i.e. WSDL-web service) or bottom up (i.e. web service – WSDL) approach .  Metro is supporting both approaches. It provides command line/ant tasks utilities (same as wsdl2java and java2wsdl). If you are using NetBeans IDE then it will generate artifacts in few clicks. You will also find eclipse plugin for the same.&lt;/p&gt;  &lt;p&gt;Let me explain steps to develop simple JAX-WS service using Metro RI.  Here I am talking about top-down approach (which is recommended in web service development).&lt;/p&gt;  &lt;p&gt;1) Design your wsdl first. You can use either doc/literal or rpc/encoded. Now a days most of the applications are using doc/literal style of web service. I have also used same style. &lt;/p&gt;  &lt;div    style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background- margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px;  direction: ltr; max-height: 200px;  overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:#f4f4f4;" id="codeSnippetWrapper"&gt;   &lt;div    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;" id="codeSnippet"&gt;     &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum1"  style="color:#606060;"&gt;   1:&lt;/span&gt; &amp;lt;?xml version=&lt;span style="color:#006080;"&gt;"1.0"&lt;/span&gt; encoding=&lt;span style="color:#006080;"&gt;"UTF-8"&lt;/span&gt; standalone=&lt;span style="color:#006080;"&gt;"no"&lt;/span&gt;?&amp;gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum2"  style="color:#606060;"&gt;   2:&lt;/span&gt; &amp;lt;wsdl:definitions xmlns:soap=&lt;span style="color:#006080;"&gt;"http://schemas.xmlsoap.org/wsdl/soap/"&lt;/span&gt;&lt;/pre&gt;&lt;span class="Apple-style-span"   style="  white-space: pre; font-family:monospace;font-size:13px;"&gt;&lt;span id="lnum3"  style="color:#606060;"&gt;   3:&lt;/span&gt;     xmlns:tns=&lt;span style="color:#006080;"&gt;"http://hello.jaxws.webservice.com"&lt;/span&gt; xmlns:wsdl=&lt;span style="color:#006080;"&gt;"http://schemas.xmlsoap.org/wsdl/"&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"   style="  white-space: pre; font-family:monospace;font-size:13px;"&gt;&lt;span id="lnum4"  style="color:#606060;"&gt;   4:&lt;/span&gt;     xmlns:xsd=&lt;span style="color:#006080;"&gt;"http://www.w3.org/2001/XMLSchema"&lt;/span&gt; name=&lt;span style="color:#006080;"&gt;"HelloService"&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"   style="  white-space: pre; font-family:monospace;font-size:13px;"&gt;&lt;span id="lnum5"  style="color:#606060;"&gt;   5:&lt;/span&gt;     targetNamespace=&lt;span style="color:#006080;"&gt;"http://hello.jaxws.webservice.com"&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"   style="  white-space: pre; font-family:monospace;font-size:13px;"&gt;&lt;span id="lnum6"  style="color:#606060;"&gt;   6:&lt;/span&gt;     &amp;lt;wsdl:types&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"   style="  white-space: pre; font-family:monospace;font-size:13px;"&gt;&lt;span id="lnum7"  style="color:#606060;"&gt;   7:&lt;/span&gt;         &amp;lt;xsd:schema targetNamespace=&lt;span style="color:#006080;"&gt;"http://hello.jaxws.webservice.com"&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"   style="  white-space: pre; font-family:monospace;font-size:13px;"&gt;&lt;span id="lnum8"  style="color:#606060;"&gt;   8:&lt;/span&gt;             &amp;lt;xsd:element name=&lt;span style="color:#006080;"&gt;"HelloJAXWSServiceRequest"&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"   style="  white-space: pre; font-family:monospace;font-size:13px;"&gt;&lt;span id="lnum9"  style="color:#606060;"&gt;   9:&lt;/span&gt;                 &amp;lt;xsd:complexType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"   style="  white-space: pre; font-family:monospace;font-size:13px;"&gt;&lt;span id="lnum10"  style="color:#606060;"&gt;  10:&lt;/span&gt;                     &amp;lt;xsd:sequence&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"   style="  white-space: pre; font-family:monospace;font-size:13px;"&gt;&lt;span id="lnum11"  style="color:#606060;"&gt;  11:&lt;/span&gt;                         &amp;lt;xsd:element name=&lt;span style="color:#006080;"&gt;"in"&lt;/span&gt; type=&lt;span style="color:#006080;"&gt;"xsd:string"&lt;/span&gt; /&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"   style="  white-space: pre; font-family:monospace;font-size:13px;"&gt;&lt;span id="lnum12"  style="color:#606060;"&gt;  12:&lt;/span&gt;                     &amp;lt;/xsd:sequence&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"   style="  white-space: pre; font-family:monospace;font-size:13px;"&gt;&lt;span id="lnum13"  style="color:#606060;"&gt;  13:&lt;/span&gt;                 &amp;lt;/xsd:complexType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"   style="  white-space: pre; font-family:monospace;font-size:13px;"&gt;&lt;span id="lnum14"  style="color:#606060;"&gt;  14:&lt;/span&gt;             &amp;lt;/xsd:element&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"   style="  white-space: pre; font-family:monospace;font-size:13px;"&gt;&lt;span id="lnum15"  style="color:#606060;"&gt;  15:&lt;/span&gt;             &amp;lt;xsd:element name=&lt;span style="color:#006080;"&gt;"HelloJAXWSServiceResponse"&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"   style="  white-space: pre; font-family:monospace;font-size:13px;"&gt;&lt;span id="lnum16"  style="color:#606060;"&gt;  16:&lt;/span&gt;                 &amp;lt;xsd:complexType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"   style="  white-space: pre; font-family:monospace;font-size:13px;"&gt;&lt;span id="lnum17"  style="color:#606060;"&gt;  17:&lt;/span&gt;                     &amp;lt;xsd:sequence&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"   style="  white-space: pre; font-family:monospace;font-size:13px;"&gt;&lt;span id="lnum18"  style="color:#606060;"&gt;  18:&lt;/span&gt;                         &amp;lt;xsd:element name=&lt;span style="color:#006080;"&gt;"out"&lt;/span&gt; type=&lt;span style="color:#006080;"&gt;"xsd:string"&lt;/span&gt; /&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"   style="  white-space: pre; font-family:monospace;font-size:13px;"&gt;&lt;span id="lnum19"  style="color:#606060;"&gt;  19:&lt;/span&gt;                     &amp;lt;/xsd:sequence&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"   style="  white-space: pre; font-family:monospace;font-size:13px;"&gt;&lt;span id="lnum20"  style="color:#606060;"&gt;  20:&lt;/span&gt;                 &amp;lt;/xsd:complexType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"   style="  white-space: pre; font-family:monospace;font-size:13px;"&gt;&lt;span id="lnum21"  style="color:#606060;"&gt;  21:&lt;/span&gt;             &amp;lt;/xsd:element&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"   style="  white-space: pre; font-family:monospace;font-size:13px;"&gt;&lt;span id="lnum22"  style="color:#606060;"&gt;  22:&lt;/span&gt;         &amp;lt;/xsd:schema&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"   style="  white-space: pre; font-family:monospace;font-size:13px;"&gt;&lt;span id="lnum23"  style="color:#606060;"&gt;  23:&lt;/span&gt;     &amp;lt;/wsdl:types&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"   style="  white-space: pre; font-family:monospace;font-size:13px;"&gt;&lt;span id="lnum24"  style="color:#606060;"&gt;  24:&lt;/span&gt;     &amp;lt;wsdl:message name=&lt;span style="color:#006080;"&gt;"HelloJAXWSServiceRequest"&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"   style="  white-space: pre; font-family:monospace;font-size:13px;"&gt;&lt;span id="lnum25"  style="color:#606060;"&gt;  25:&lt;/span&gt;         &amp;lt;wsdl:part element=&lt;span style="color:#006080;"&gt;"tns:HelloJAXWSServiceRequest"&lt;/span&gt; name=&lt;span style="color:#006080;"&gt;"parameters"&lt;/span&gt; /&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"   style="  white-space: pre; font-family:monospace;font-size:13px;"&gt;&lt;span id="lnum26"  style="color:#606060;"&gt;  26:&lt;/span&gt;     &amp;lt;/wsdl:message&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"   style="  white-space: pre; font-family:monospace;font-size:13px;"&gt;&lt;span id="lnum27"  style="color:#606060;"&gt;  27:&lt;/span&gt;     &amp;lt;wsdl:message name=&lt;span style="color:#006080;"&gt;"HelloJAXWSServiceResponse"&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"   style="  white-space: pre; font-family:monospace;font-size:13px;"&gt;&lt;span id="lnum28"  style="color:#606060;"&gt;  28:&lt;/span&gt;         &amp;lt;wsdl:part element=&lt;span style="color:#006080;"&gt;"tns:HelloJAXWSServiceResponse"&lt;/span&gt; name=&lt;span style="color:#006080;"&gt;"parameters"&lt;/span&gt; /&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"   style="  white-space: pre; font-family:monospace;font-size:13px;"&gt;&lt;span id="lnum29"  style="color:#606060;"&gt;  29:&lt;/span&gt;     &amp;lt;/wsdl:message&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"   style="  white-space: pre; font-family:monospace;font-size:13px;"&gt;&lt;span id="lnum30"  style="color:#606060;"&gt;  30:&lt;/span&gt;     &amp;lt;wsdl:portType name=&lt;span style="color:#006080;"&gt;"HelloService"&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"   style="  white-space: pre; font-family:monospace;font-size:13px;"&gt;&lt;span id="lnum31"  style="color:#606060;"&gt;  31:&lt;/span&gt;         &amp;lt;wsdl:operation name=&lt;span style="color:#006080;"&gt;"HelloJAXWSService"&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"   style="  white-space: pre; font-family:monospace;font-size:13px;"&gt;&lt;span id="lnum32"  style="color:#606060;"&gt;  32:&lt;/span&gt;             &amp;lt;wsdl:input message=&lt;span style="color:#006080;"&gt;"tns:HelloJAXWSServiceRequest"&lt;/span&gt; /&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"   style="  white-space: pre; font-family:monospace;font-size:13px;"&gt;&lt;span id="lnum33"  style="color:#606060;"&gt;  33:&lt;/span&gt;             &amp;lt;wsdl:output message=&lt;span style="color:#006080;"&gt;"tns:HelloJAXWSServiceResponse"&lt;/span&gt; /&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"   style="  white-space: pre; font-family:monospace;font-size:13px;"&gt;&lt;span id="lnum34"  style="color:#606060;"&gt;  34:&lt;/span&gt;         &amp;lt;/wsdl:operation&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"   style="  white-space: pre; font-family:monospace;font-size:13px;"&gt;&lt;span id="lnum35"  style="color:#606060;"&gt;  35:&lt;/span&gt;     &amp;lt;/wsdl:portType&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"   style="  white-space: pre; font-family:monospace;font-size:13px;"&gt;&lt;span id="lnum36"  style="color:#606060;"&gt;  36:&lt;/span&gt;     &amp;lt;wsdl:binding name=&lt;span style="color:#006080;"&gt;"HelloServiceSOAP"&lt;/span&gt; type=&lt;span style="color:#006080;"&gt;"tns:HelloService"&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"   style="  white-space: pre; font-family:monospace;font-size:13px;"&gt;&lt;span id="lnum37"  style="color:#606060;"&gt;  37:&lt;/span&gt;         &amp;lt;soap:binding style=&lt;span style="color:#006080;"&gt;"document"&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"   style="  white-space: pre; font-family:monospace;font-size:13px;"&gt;&lt;span id="lnum38"  style="color:#606060;"&gt;  38:&lt;/span&gt;             transport=&lt;span style="color:#006080;"&gt;"http://schemas.xmlsoap.org/soap/http"&lt;/span&gt; /&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"   style="  white-space: pre; font-family:monospace;font-size:13px;"&gt;&lt;span id="lnum39"  style="color:#606060;"&gt;  39:&lt;/span&gt;         &amp;lt;wsdl:operation name=&lt;span style="color:#006080;"&gt;"HelloJAXWSService"&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"   style="  white-space: pre; font-family:monospace;font-size:13px;"&gt;&lt;span id="lnum40"  style="color:#606060;"&gt;  40:&lt;/span&gt;             &amp;lt;soap:operation soapAction=&lt;span style="color:#006080;"&gt;"http://www.example.org/HelloService/NewOperation"&lt;/span&gt; /&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"   style="  white-space: pre; font-family:monospace;font-size:13px;"&gt;&lt;span id="lnum44"  style="color:#606060;"&gt;  44:&lt;/span&gt;             &amp;lt;wsdl:output&amp;gt;&lt;/span&gt;&lt;br /&gt; &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum45"  style="color:#606060;"&gt;  45:&lt;/span&gt;                 &amp;lt;soap:body use=&lt;span style="color:#006080;"&gt;"literal"&lt;/span&gt; /&amp;gt;&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum46"  style="color:#606060;"&gt;  46:&lt;/span&gt;             &amp;lt;/wsdl:output&amp;gt;&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum47"  style="color:#606060;"&gt;  47:&lt;/span&gt;         &amp;lt;/wsdl:operation&amp;gt;&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum48"  style="color:#606060;"&gt;  48:&lt;/span&gt;     &amp;lt;/wsdl:binding&amp;gt;&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum49"  style="color:#606060;"&gt;  49:&lt;/span&gt;     &amp;lt;wsdl:service name=&lt;span style="color:#006080;"&gt;"HelloService"&lt;/span&gt;&amp;gt;&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum50"  style="color:#606060;"&gt;  50:&lt;/span&gt;         &amp;lt;wsdl:port binding=&lt;span style="color:#006080;"&gt;"tns:HelloServiceSOAP"&lt;/span&gt; name=&lt;span style="color:#006080;"&gt;"HelloServiceSOAP"&lt;/span&gt;&amp;gt;&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum51"  style="color:#606060;"&gt;  51:&lt;/span&gt;             &amp;lt;soap:address location=&lt;span style="color:#006080;"&gt;"http://localhost:8080/helloservice/HelloWebService"&lt;/span&gt; /&amp;gt;&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum52"  style="color:#606060;"&gt;  52:&lt;/span&gt;         &amp;lt;/wsdl:port&amp;gt;&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum53"  style="color:#606060;"&gt;  53:&lt;/span&gt;     &amp;lt;/wsdl:service&amp;gt;&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum54"  style="color:#606060;"&gt;  54:&lt;/span&gt; &amp;lt;/wsdl:definitions&amp;gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;2) Add &lt;strong&gt;ws-import&lt;/strong&gt; task in your ant script. Make sure you have jax-ws libraries in classpath before executing it. (note: to execute this task from build script, just add jaxws-tools.jar in Ant classpath)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div    style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background- margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px;  direction: ltr; max-height: 200px;  overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:#f4f4f4;" id="codeSnippetWrapper"&gt;&lt;div    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;" id="codeSnippet"&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum1"  style="color:#606060;"&gt;   1:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;taskdef&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="wsimport"&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;classname&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="com.sun.tools.ws.ant.WsImport"&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum2"  style="color:#606060;"&gt;   2:&lt;/span&gt;      &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;classpath&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;refid&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="jaxws.classpath"&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum3"  style="color:#606060;"&gt;   3:&lt;/span&gt;  &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;taskdef&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;3)  add below target to generate jax-ws artifacts using ws-import task.&lt;/p&gt;&lt;div    style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background- margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px;  direction: ltr; max-height: 200px;  overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:#f4f4f4;" id="codeSnippetWrapper"&gt;&lt;div    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;" id="codeSnippet"&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum1"  style="color:#606060;"&gt;   1:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;target&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="wsgeneration"&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;description&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="generating jax-ws artifacts"&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum2"  style="color:#606060;"&gt;   2:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;wsimport&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;wsdl&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="${basedir}/WebContent/WEB-INF/wsdl/HelloService.wsdl"&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum3"  style="color:#606060;"&gt;   3:&lt;/span&gt;             &lt;span style="color:#ff0000;"&gt;destdir&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="${build.home}"&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;sourcedestdir&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="${root}/src"&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;verbose&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="true"&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum4"  style="color:#606060;"&gt;   4:&lt;/span&gt;             &lt;span style="color:#ff0000;"&gt;keep&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="true"&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum5"  style="color:#606060;"&gt;   5:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;wsimport&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;    &lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum6"  style="color:#606060;"&gt;   6:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;target&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;I have shown basic attributes here for generating artifacts. “wsdl” contains wsdl location (you can keep it anywhere). “dest-dir” should be directory in which generated artifact classes will be placed. “sourcedestdir” contains generated source files. &lt;/p&gt;&lt;p&gt;Successful execution of buid script will generate below set of artifacts.(&lt;strong&gt;Note&lt;/strong&gt;: Below list may vary depending upon your schema definition)&lt;/p&gt;&lt;p&gt;HelloJAXWSServiceRequest.java (request object as defined in wsdl)&lt;br /&gt;HelloJAXWSServiceResponse.java(response object as defined in wsdl&lt;br /&gt;HelloService_Service.java&lt;br /&gt;HelloService.java (SEI – service endpoint interface)&lt;br /&gt;ObjectFactory.java (annotated source files)&lt;br /&gt;package-info.java &lt;/p&gt;&lt;p&gt;4) Now create an implementation class say HelloServiceImpl which implements SEI (i.e. HelloService here)&lt;/p&gt;&lt;div    style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background- margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px;  direction: ltr; max-height: 200px;  overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:#f4f4f4;" id="codeSnippetWrapper"&gt;&lt;div    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;" id="codeSnippet"&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum1"  style="color:#606060;"&gt;  1:&lt;/span&gt; &lt;span style="color:#008000;"&gt;/**&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum2"  style="color:#606060;"&gt;   2:&lt;/span&gt; &lt;span style="color:#008000;"&gt; * &lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum3"  style="color:#606060;"&gt;   3:&lt;/span&gt; &lt;span style="color:#008000;"&gt; */&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum4"  style="color:#606060;"&gt;   4:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;package&lt;/span&gt; com.webservice.jaxws.hello;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum5"  style="color:#606060;"&gt;   5:&lt;/span&gt;  &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum6"  style="color:#606060;"&gt;   6:&lt;/span&gt; &lt;span style="color:#008000;"&gt;/**&lt;span class="Apple-style-span" style="color: rgb(0, 0, 0); "&gt;&lt;span id="lnum7"  style="color:#606060;"&gt;   &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span style="color:#008000;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 0); "&gt;&lt;span id="lnum7"  style="color:#606060;"&gt;   7:&lt;/span&gt; &lt;span style="color:#008000;"&gt; * @author chintz&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum8"  style="color:#606060;"&gt;   8:&lt;/span&gt; &lt;span style="color:#008000;"&gt; *&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum9"  style="color:#606060;"&gt;   9:&lt;/span&gt; &lt;span style="color:#008000;"&gt; */&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum10"  style="color:#606060;"&gt;  10:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;class&lt;/span&gt; HelloServiceImpl &lt;span style="color:#0000ff;"&gt;implements&lt;/span&gt; HelloService {&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum13"  style="color:#606060;"&gt;  13:&lt;/span&gt;     @Override&lt;/pre&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum14"  style="color:#606060;"&gt;  14:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; HelloJAXWSServiceResponse helloJAXWSService(&lt;/pre&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum15"  style="color:#606060;"&gt;  15:&lt;/span&gt;             HelloJAXWSServiceRequest parameters) {&lt;/pre&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum17"  style="color:#606060;"&gt;  17:&lt;/span&gt;         &lt;span style="color:#008000;"&gt;//get web service in parameters from request&lt;/span&gt;&lt;/pre&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum18"  style="color:#606060;"&gt;  18:&lt;/span&gt;         String inParam = parameters.getIn();&lt;/pre&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum20"  style="color:#606060;"&gt;  20:&lt;/span&gt;         &lt;span style="color:#008000;"&gt;//do some processing&lt;/span&gt;&lt;/pre&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum21"  style="color:#606060;"&gt;  21:&lt;/span&gt;         String response = &lt;span style="color:#006080;"&gt;"Hello"&lt;/span&gt; + inParam;&lt;/pre&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum23"  style="color:#606060;"&gt;  23:&lt;/span&gt;         &lt;span style="color:#008000;"&gt;//set response in HelloJAXWSServiceResponse object&lt;/span&gt;&lt;/pre&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum24"  style="color:#606060;"&gt;  24:&lt;/span&gt;         HelloJAXWSServiceResponse wsRes = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; HelloJAXWSServiceResponse();&lt;/pre&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum25"  style="color:#606060;"&gt;  25:&lt;/span&gt;         wsRes.setOut(response);&lt;/pre&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum27"  style="color:#606060;"&gt;  27:&lt;/span&gt;         &lt;span style="color:#008000;"&gt;//return response&lt;/span&gt;&lt;/pre&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum28"  style="color:#606060;"&gt;  28:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; wsRes;&lt;/pre&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum29"  style="color:#606060;"&gt;  29:&lt;/span&gt;     }&lt;/pre&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum31"  style="color:#606060;"&gt;  31:&lt;/span&gt; }&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;span class="Apple-style-span" style="line-height: 16px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;p&gt;5) Add JAX-WS listener and servlet entries in web.xml. This listener and servlet is useful in initializing JAX-WS runtime.  Listener is same like Spring’s ServletContextLoaderListener whose job is to initialize Spring framework. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;div    style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background- margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px;  direction: ltr; max-height: 200px;  overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:#f4f4f4;" id="codeSnippetWrapper"&gt;&lt;div    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;" id="codeSnippet"&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum1"  style="color:#606060;"&gt;   1:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;listener&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum2"  style="color:#606060;"&gt;   2:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;listener-class&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;com.sun.xml.ws.transport.http.servlet.WSServletContextListener&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;listener-class&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum3"  style="color:#606060;"&gt;   3:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;listener&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum4"  style="color:#606060;"&gt;   4:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;servlet&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum5"  style="color:#606060;"&gt;   5:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;description&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;JAX-WS endpoint&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;description&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum6"  style="color:#606060;"&gt;   6:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;display-name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;JAXWS servlet&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;display-name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum7"  style="color:#606060;"&gt;   7:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;servlet-name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;helloservice&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;servlet-name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum8"  style="color:#606060;"&gt;   8:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;servlet-class&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;com.sun.xml.ws.transport.http.servlet.WSServlet&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;servlet-class&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum9"  style="color:#606060;"&gt;   9:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;load-on-startup&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;1&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;load-on-startup&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum10"  style="color:#606060;"&gt;  10:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;servlet&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum11"  style="color:#606060;"&gt;  11:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;servlet-mapping&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum12"  style="color:#606060;"&gt;  12:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;servlet-name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;helloservice&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;servlet-name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum13"  style="color:#606060;"&gt;  13:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;url-pattern&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;/helloservice&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;url-pattern&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum14"  style="color:#606060;"&gt;  14:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;servlet-mapping&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;6) Create sun-jaxws.xml which contains endpoint implementation details. &lt;/p&gt;&lt;div    style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background- margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px;  direction: ltr; max-height: 200px;  overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:#f4f4f4;" id="codeSnippetWrapper"&gt;&lt;div    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;" id="codeSnippet"&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum1"  style="color:#606060;"&gt;   1:&lt;/span&gt; &amp;lt;endpoints xmlns=&lt;span style="color:#006080;"&gt;'http://java.sun.com/xml/ns/jax-ws/ri/runtime'&lt;/span&gt; version=&lt;span style="color:#006080;"&gt;'2.0'&lt;/span&gt;&amp;gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum2"  style="color:#606060;"&gt;   2:&lt;/span&gt;     &amp;lt;endpoint&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum3"  style="color:#606060;"&gt;   3:&lt;/span&gt;         name=&lt;span style="color:#006080;"&gt;'helloService'&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum4"  style="color:#606060;"&gt;   4:&lt;/span&gt;         implementation=&lt;span style="color:#006080;"&gt;'com.webservice.jaxws.hello.HelloServiceImpl'&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum5"  style="color:#606060;"&gt;   5:&lt;/span&gt;         url-pattern=&lt;span style="color:#006080;"&gt;'/helloservice'&lt;/span&gt;/&amp;gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre    style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px;  direction: ltr; border-top-style: none;   border-left-style: none; overflow: visible; padding-top: 0pxfont-family:'Courier New', courier, monospace;font-size:8pt;color:black;"&gt;&lt;span id="lnum6"  style="color:#606060;"&gt;   6:&lt;/span&gt; &amp;lt;/endpoints&amp;gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;span class="Apple-style-span" style="line-height: 16px;"&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="line-height: normal; "&gt;So whenever any request comes with defined url-pattern (in our case “helloservice”) it will look for service implementation details from sun-jaxws.xml and execute corresponding service method.&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;Now bundle everything in WAR file and deploy it. If you see message like “Initialized WSServlet” and “JAX-WS framework ready” (on server console) during deployment it means that you are all set.&lt;br /&gt;Verify your service deployment by accessing: (&lt;a title="http://localhost:8080/helloservice/HelloWebService" href="http://localhost:8080/helloservice/HelloWebService"&gt;http://localhost:8080/helloservice/HelloWebService&lt;/a&gt;) or wsdl (&lt;a title="http://localhost:8080/helloservice/HelloWebService" href="http://localhost:8080/helloservice/HelloWebService?wsdl"&gt;http://localhost:8080/helloservice/HelloWebService?wsdl&lt;/a&gt;)&lt;br /&gt;&lt;br /&gt;So your simple Hello JAX-WS service ready. Now test it using client application. To start with, test it using SoapUI tool.&lt;br /&gt;&lt;br /&gt;Hope this article will help you in developing JAX-WS service.</description><link>http://chintanpparekh.blogspot.com/2009/12/develop-simple-jax-ws-web-service-using.html</link><author>noreply@blogger.com (Chintan Parekh)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7164483852868486084.post-6726399351692655682</guid><pubDate>Thu, 25 Jun 2009 14:44:00 +0000</pubDate><atom:updated>2009-12-13T19:56:18.582+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Spring</category><category domain="http://www.blogger.com/atom/ns#">Technical</category><title>Introduction to Spring Security</title><description>&lt;p&gt;Recently I have given presentation on Spring Security framework. Before I talk about Spring Security, I will brief you about what is all about security framework and why it is really important?&lt;/p&gt;  &lt;p&gt;You must have heard word “Security” many times. In your day-to-day life as well as while writing a simple computer program. Dictionary meaning of &lt;strong&gt;Security&lt;/strong&gt; is “&lt;i&gt;degree of protection against danger, lost and criminals&lt;/i&gt;”. Well “&lt;i&gt;Criminals&lt;/i&gt;” in computer world is none other than “&lt;i&gt;Hacker&lt;/i&gt;”. :) I hope you are aware of what does “&lt;i&gt;Hacker&lt;/i&gt;” mean? :) &lt;/p&gt;  &lt;p&gt;So let’s see how Security is important for an enterprise and it’s software applications. In today’s world security has become ever-moving target for an enterprise. All enterprise wants their system to be as secure as possible in its own right. In IT realm security is categorized as “Layers of Security”. i.e.each layer should be secured enough. There are 4 Layers of Security which are listed below.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Transport Layer Security –&lt;/strong&gt;  this is generally achieved using SSL protocol. provides security and data integrity over network such as internet, intranet, VPN.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Network Security&lt;/strong&gt; – this is achieved using IPSec&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Data/Information Security – &lt;/strong&gt;this can be achieved using message encryption techniques like using X.509 Certificate.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Application Security &lt;/strong&gt;– this is generally achieved using Security frameworks like Spring Security, Java EE Security.&lt;/p&gt;  &lt;p&gt;I believe you must have learnt “layers of security” during your Engineering/Graduation (probably as a part of “Computer Networking” subject) :). No worries if you have forgotten, I will help you to give basic understanding..if you still not understand. you can search on google!!!!! :) &lt;/p&gt;  &lt;p&gt;Now let’s get back to our main topic…&lt;/p&gt;  &lt;p&gt;Here I will talk about Application Security which is taken care by security framework like Spring Security. Security framework generally take care of Authentication, Authorization (i.e. Access Control mechanism), Encryption, Session management (i.e. preventing men-in-middle attack, session hijacking) , Auditing and logging. &lt;/p&gt;  &lt;p&gt;Now let’s talk about what is Spring Security (aka Acegi Security)? Earlier it was known as Acegi Security framework which is merged with Spring and now known as Spring Security framework.&lt;/p&gt;  &lt;p&gt;Spring Security provides comprehensive services (i.e. Authentication, Authorization, Encryption, etc) for J2EE based enterprise s/w application.&lt;/p&gt;  &lt;p&gt;Let me talk about why this framework is gaining popularity.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;strong&gt;Lack of depth of security in Servlet and EJB Specifications&lt;/strong&gt;. These specifications support primary authentication and authorization services like BASIC, FORM and Digest authentication and method level authorization services. &lt;/li&gt;    &lt;li&gt;Again &lt;strong&gt;they are not portable at EAR and WAR level &lt;/strong&gt;so if you switch to other Application Server environment, you may have to reconfigure these settings. &lt;/li&gt;    &lt;li&gt;Since Spring Security is built upon Core Spring, you can leverage core spring features like Dependency Injection (DI), AOP (Aspect Oriented Programming), PropertyConfigurator, etc. &lt;/li&gt;    &lt;li&gt;Apart from that Spring Security provides dozen of useful, entirely customizable security features. I will discuss few of them here. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Now let’s talk about Spring Authentication and Authorization one-by-one.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Authentication i.e. “Check if the principal (i.e. users or system) is who he/she says he/she is&lt;/strong&gt;”.&lt;/p&gt;  &lt;p&gt;Sprint Security provides easy integration with different types of authentication mechanism. I have listed few of them below. You can get full list in Spring Security docs.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;HTTP BASIC authentication &lt;/li&gt;    &lt;li&gt;HTTP Digest authentication &lt;/li&gt;    &lt;li&gt;HTTP Form based authentication &lt;/li&gt;    &lt;li&gt;HTTP X.509 client certificate exchange &lt;/li&gt;    &lt;li&gt;LDAP &lt;/li&gt;    &lt;li&gt;OpenID authentication (OpenID is also gaining popularity and major companies liek Google, Microsoft, Sun, Oracle, Yahoo support OpenID authentication) you can get more details on &lt;a title="http://en.wikipedia.org/wiki/OpenID" href="http://en.wikipedia.org/wiki/OpenID"&gt;http://en.wikipedia.org/wiki/OpenID&lt;/a&gt; ) &lt;/li&gt;    &lt;li&gt;Computer Associates Siteminder &lt;/li&gt;    &lt;li&gt;Central Authentication Service ( known as CAS package, a popular Single Sign-On (SSO) system) &lt;/li&gt;    &lt;li&gt;“Remember-me” authentication &lt;/li&gt;    &lt;li&gt;Anonymous, Run-as and JAAS (Java Authentication and Authorization Service) &lt;/li&gt;    &lt;li&gt;Also support for container( i.e. Tomcat, JBoss, Jetty) based authentication mechanism &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Apart from above listed support, framework also provides integration with Grails, Mule ESB, Tapestry and last but not the least your own Authentication Mechanism. Spring also supports Channel Security (through HTTPS) with JCaptcha (a java based s/w application to ensure that response is not generated by computer).&lt;/p&gt;  &lt;p&gt;i have talked much about authentication support provided by framework. Now let’s discuss about authorization support provided by framework.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Authorization i.e. “how an application grants access to content and functions to some principals  and not others&lt;/strong&gt;”&lt;/p&gt;  &lt;p&gt;Advanced authorization capabilities is one of the reason for gaining popularity of this framework. Irrespective of your authentication mechanism, you can use framework’s Authorization services in your application.&lt;/p&gt;  &lt;p&gt;So if we go by the definition of authorization, we want service layers methods and objects to be accessed by specific users based on roles defined either in the property file, database,LDAP or some other repositories. Spring Security provides three types of interceptors to achieve this functionality.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;AOP Alliance (MethodInvocation) Security Interceptor&lt;/li&gt;    &lt;li&gt;AspectJ (JoinPoint) Security Interceptor&lt;/li&gt;    &lt;li&gt;FilterInvocation Security Interceptor&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Don’t think how these interceptor works, i will discuss it in next article. For your knowledge, Interceptors are used to intercept request and do some processing on it, like authentication, authorization, logging, auditing, etc.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;Note&lt;/u&gt;&lt;/strong&gt;: All authentication and authorization is provided by Spring Security framework is based on various Filters.  I will discuss this in detail in next article.&lt;/p&gt;  &lt;p&gt;I hope you have now basic understanding of Spring Security and it’s features. In next article i will show you example how simple web application can be easily configured with Spring Security. It is more configuration based and less coding..i am sure you must be happy :)&lt;/p&gt;  &lt;p&gt;I would suggest you to also explore other security frameworks in J2EE arena, like &lt;strong&gt;Java EE Security, OWASP&lt;/strong&gt;(Open Web Application Security Project) &lt;strong&gt;Enterprise Security API,&lt;/strong&gt; BoncyCastle, jGuard. &lt;/p&gt;  &lt;p&gt;Don’t forget to visit my next article which will be continuation of this!!!!  Have a nice day :)&lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;ul&gt;   &lt;p&gt; &lt;/p&gt; &lt;/ul&gt;</description><link>http://chintanpparekh.blogspot.com/2009/06/introduction-to-spring-security.html</link><author>noreply@blogger.com (Chintan Parekh)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7164483852868486084.post-4652243171601523828</guid><pubDate>Tue, 19 May 2009 13:50:00 +0000</pubDate><atom:updated>2009-12-13T19:55:31.054+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Hibernate</category><category domain="http://www.blogger.com/atom/ns#">Technical</category><title>Hibernate session.get () Vs session.load ()</title><description>&lt;p&gt;&lt;a href="http://feeds2.feedburner.com/ChintanParekhsBlog" rel="alternate" type="application/rss+xml"&gt;&lt;img src="http://www.feedburner.com/fb/images/pub/feed-icon16x16.png" alt="" style="vertical-align:middle;border:0" /&gt;&lt;/a&gt; &lt;a href="http://feeds2.feedburner.com/ChintanParekhsBlog" rel="alternate" type="application/rss+xml"&gt;Subscribe in a reader&lt;/a&gt;&lt;/p&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate="false" latentstylecount="156"&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Font Definitions */  @font-face  {font-family:Wingdings;  panose-1:5 0 0 0 0 0 0 0 0 0;  mso-font-charset:2;  mso-generic-font-family:auto;  mso-font-pitch:variable;  mso-font-signature:0 268435456 0 0 -2147483648 0;}  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal  {mso-style-parent:"";  margin:0in;  margin-bottom:.0001pt;  mso-pagination:widow-orphan;  font-size:12.0pt;  font-family:"Times New Roman";  mso-fareast-font-family:"Times New Roman";} @page Section1  {size:8.5in 11.0in;  margin:1.0in 1.25in 1.0in 1.25in;  mso-header-margin:.5in;  mso-footer-margin:.5in;  mso-paper-source:0;} div.Section1  {page:Section1;}  /* List Definitions */  @list l0  {mso-list-id:446824567;  mso-list-type:hybrid;  mso-list-template-ids:-404820132 67698689 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;} @list l0:level1  {mso-level-number-format:bullet;  mso-level-text:;  mso-level-tab-stop:.75in;  mso-level-number-position:left;  margin-left:.75in;  text-indent:-.25in;  font-family:Symbol;} @list l0:level2  {mso-level-tab-stop:1.0in;  mso-level-number-position:left;  text-indent:-.25in;} @list l0:level3  {mso-level-tab-stop:1.5in;  mso-level-number-position:left;  text-indent:-.25in;} @list l0:level4  {mso-level-tab-stop:2.0in;  mso-level-number-position:left;  text-indent:-.25in;} @list l0:level5  {mso-level-tab-stop:2.5in;  mso-level-number-position:left;  text-indent:-.25in;} @list l0:level6  {mso-level-tab-stop:3.0in;  mso-level-number-position:left;  text-indent:-.25in;} @list l0:level7  {mso-level-tab-stop:3.5in;  mso-level-number-position:left;  text-indent:-.25in;} @list l0:level8  {mso-level-tab-stop:4.0in;  mso-level-number-position:left;  text-indent:-.25in;} @list l0:level9  {mso-level-tab-stop:4.5in;  mso-level-number-position:left;  text-indent:-.25in;} @list l1  {mso-list-id:833104172;  mso-list-type:hybrid;  mso-list-template-ids:2143998052 67698689 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;} @list l1:level1  {mso-level-number-format:bullet;  mso-level-text:;  mso-level-tab-stop:.5in;  mso-level-number-position:left;  text-indent:-.25in;  font-family:Symbol;} ol  {margin-bottom:0in;} ul  {margin-bottom:0in;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable  {mso-style-name:"Table Normal";  mso-tstyle-rowband-size:0;  mso-tstyle-colband-size:0;  mso-style-noshow:yes;  mso-style-parent:"";  mso-padding-alt:0in 5.4pt 0in 5.4pt;  mso-para-margin:0in;  mso-para-margin-bottom:.0001pt;  mso-pagination:widow-orphan;  font-size:10.0pt;  font-family:"Times New Roman";  mso-ansi-language:#0400;  mso-fareast-language:#0400;  mso-bidi-language:#0400;} &lt;/style&gt; &lt;![endif]--&gt;  &lt;/div&gt;&lt;p style="text-align: justify;" class="MsoNormal"&gt;In my recent assignment, we had a requirement to fetch a single row from DB (i.e. entity) using Hibernate framework. So &lt;b style=""&gt;Session.get(&lt;a href="http://java.sun.com/j2se/1.3/docs/api/java/lang/Class.html" title="class or interface in java.lang"&gt;&lt;span style="text-decoration: none; color: rgb(0, 0, 0);"&gt;Class&lt;/span&gt;&lt;/a&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;clazz&lt;/span&gt;, &lt;a href="http://java.sun.com/j2se/1.3/docs/api/java/io/Serializable.html" title="class or interface in java.io"&gt;&lt;span style="text-decoration: none; color: rgb(0, 0, 0);"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;Serializable&lt;/span&gt;&lt;/span&gt;&lt;/a&gt; id)&lt;/b&gt; straightaway came into my mind.  However&lt;br /&gt;&lt;/p&gt;&lt;p style="text-align: justify;" class="MsoNormal"&gt;there is one more function named &lt;b style=""&gt;Session.load(&lt;a href="http://java.sun.com/j2se/1.3/docs/api/java/lang/Class.html" title="class or interface in java.lang"&gt;&lt;span style="text-decoration: none; color: rgb(0, 0, 0);"&gt;Class&lt;/span&gt;&lt;/a&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;theClass&lt;/span&gt;, &lt;a href="http://java.sun.com/j2se/1.3/docs/api/java/io/Serializable.html" title="class or interface in java.io"&gt;&lt;span style="text-decoration: none; color: rgb(0, 0, 0);"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_3"&gt;Serializable&lt;/span&gt;&lt;/span&gt;&lt;/a&gt; id) &lt;/b&gt;to achieve same functionality.&lt;br /&gt;&lt;/p&gt;&lt;p style="text-align: justify;" class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="text-align: justify;" class="MsoNormal"&gt;Since both functions are part of Session interface, there has to be some difference between each of them. Let's see their usage and &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_4"&gt;differences&lt;/span&gt;.&lt;br /&gt;&lt;/p&gt;&lt;p style="text-align: justify;" class="MsoNormal"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="text-align: justify;"&gt;  &lt;/div&gt;&lt;p style="text-align: justify;" class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;&lt;div style="text-align: justify;"&gt;  &lt;/div&gt;&lt;p style="text-align: justify;" class="MsoNormal"&gt;&lt;b style=""&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_5"&gt;Sesion&lt;/span&gt;.get( Class &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_6"&gt;theClass&lt;/span&gt;, &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_7"&gt;Serializable&lt;/span&gt; id) throws &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_8"&gt;HibernateException&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;&lt;div style="text-align: justify;"&gt;  &lt;/div&gt;&lt;p style="text-align: justify;" class="MsoNormal"&gt;It returns persistent instance of the given entity class with the given identifier. &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_9"&gt;Incase&lt;/span&gt; of non-existence it will return null.&lt;/p&gt;&lt;p style="text-align: justify;" class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="text-align: justify;"&gt;  &lt;/div&gt;&lt;p style="text-align: justify;" class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;&lt;div style="text-align: justify;"&gt;  &lt;/div&gt;&lt;p style="text-align: justify;" class="MsoNormal"&gt;So to get an entity from the underlying persistence store, all you have to do is call Hibernate Session’s get method and provide two arguments: Java class associated with the entity that you are retrieving which in our case would be User.class and actual primary key associated with the record. i.e.&lt;/p&gt;&lt;p style="text-align: justify;" class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="text-align: justify;"&gt;  &lt;/div&gt;&lt;p style="text-align: justify;" class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;&lt;div style="text-align: justify;"&gt;  &lt;/div&gt;&lt;p class="MsoNormal" style="background: rgb(250, 250, 250) none repeat scroll 0% 0%; line-height: 16.8pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; text-align: justify;"&gt;&lt;span style=";font-family:&amp;quot;;font-size:8;"&gt;session.&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_10"&gt;beginTransaction&lt;/span&gt;();&lt;br /&gt;User user = (User)session.get(User.class, new Long(1));&lt;br /&gt;System.out.println(user.getPassword());&lt;br /&gt;session.getTransaction().commit();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="text-align: justify;"&gt;  &lt;/div&gt;&lt;p class="MsoNormal" style="background: rgb(250, 250, 250) none repeat scroll 0% 0%; line-height: 16.8pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; text-align: justify;"&gt;&lt;span style=";font-family:&amp;quot;;font-size:8;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="text-align: justify;"&gt;  &lt;/div&gt;&lt;p style="text-align: justify;" class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;&lt;div style="text-align: justify;"&gt;  &lt;/div&gt;&lt;p style="text-align: justify;" class="MsoNormal"&gt;&lt;span style=";font-family:Arial;font-size:10;"&gt;In above code, I have simply retrieved an instance of User class using get () and then printing “password” property before transaction commit.&lt;/span&gt;&lt;/p&gt;&lt;p style="text-align: justify;" class="MsoNormal"&gt;&lt;br /&gt;&lt;span style=";font-family:Arial;font-size:10;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="text-align: justify;"&gt;  &lt;/div&gt;&lt;p style="text-align: justify;" class="MsoNormal"&gt;&lt;span style=";font-family:Arial;font-size:10;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="text-align: justify;"&gt;  &lt;/div&gt;&lt;p style="text-align: justify;" class="MsoNormal"&gt;&lt;span style=";font-family:Arial;font-size:10;"&gt;Now same code, instead of get () I will use load () as below. Before that let me explain definition of session.load ()&lt;/span&gt;&lt;/p&gt;&lt;p style="text-align: justify;" class="MsoNormal"&gt;&lt;br /&gt;&lt;span style=";font-family:Arial;font-size:10;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="text-align: justify;"&gt;  &lt;/div&gt;&lt;p style="text-align: justify;" class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;&lt;div style="text-align: justify;"&gt;  &lt;/div&gt;&lt;p style="text-align: justify;" class="MsoNormal"&gt;&lt;b style=""&gt;public Object &lt;span style=""&gt;load&lt;/span&gt;(Class &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_11"&gt;theClass&lt;/span&gt;, &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_12"&gt;Serializable&lt;/span&gt; id) throws &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_13"&gt;HibernateException&lt;/span&gt;&lt;/b&gt; returns persistent instance or proxy of a class with the given identifier. We can not use this method to determine if an instance is exists. &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_14"&gt;In case&lt;/span&gt; of non-existence of the instance it will throw an exception.  &lt;!--[if !supportLineBreakNewLine]--&gt;  &lt;!--[endif]--&gt;&lt;/p&gt;&lt;div style="text-align: justify;"&gt;  &lt;/div&gt;&lt;p class="MsoNormal" style="background: rgb(250, 250, 250) none repeat scroll 0% 0%; line-height: 16.8pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; text-align: justify;"&gt;&lt;span style=";font-family:&amp;quot;;font-size:8;"&gt;session.&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_15"&gt;beginTransaction&lt;/span&gt;();&lt;br /&gt;User user = (User)session.load(User.class, new Long(1));&lt;br /&gt;System.out.println(user.getPassword());&lt;br /&gt;session.getTransaction().commit();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="text-align: justify;"&gt;  &lt;/div&gt;&lt;p style="text-align: justify;" class="MsoNormal"&gt;&lt;br /&gt;I have shown code snippet for both methods, now let’s concentrate on real part and that is comparison between these two methods.&lt;/p&gt;&lt;div style="text-align: justify;"&gt;  &lt;/div&gt;&lt;p style="text-align: justify;" class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;&lt;div style="text-align: justify;"&gt;  &lt;/div&gt;&lt;p style="text-align: justify;" class="MsoNormal"&gt;Well if you were to compare the load and the get method of Hibernate Session, it looked pretty similar, and you’d be correct. However there are subtle and importance differences.&lt;/p&gt;&lt;p style="text-align: justify;" class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="text-align: justify;"&gt;  &lt;/div&gt;&lt;p style="text-align: justify;" class="MsoNormal"&gt;First of all, the Get method hits Database as soon as it is called. So this method will always trigger a DB hit. While load method will hit the database when particular field is accessed (i.e. &lt;b style=""&gt;user.&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_16"&gt;getPassword&lt;/span&gt; ()&lt;/b&gt;) so if you use load method to retrieve an entity, but you never actually access any field of the entity, it never hits the database. I think this is pretty good&lt;span style="font-family:Wingdings;"&gt;&lt;span style=""&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="text-align: justify;" class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="text-align: justify;" class="MsoNormal"&gt;&lt;span style="font-family:Wingdings;"&gt;&lt;span style=""&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="text-align: justify;"&gt;  &lt;/div&gt;&lt;p style="text-align: justify;" class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;&lt;div style="text-align: justify;"&gt;  &lt;/div&gt;&lt;p style="text-align: justify;" class="MsoNormal"&gt;Well, actually, as per above description, load method might sound good, but it triggers more problems then it solves&lt;span style="font-family:Wingdings;"&gt;&lt;span style=""&gt;L&lt;/span&gt;&lt;/span&gt;. Let’s understand WHY?&lt;/p&gt;&lt;p style="text-align: justify;" class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="text-align: justify;"&gt;  &lt;/div&gt;&lt;p style="text-align: justify;" class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;&lt;div style="text-align: justify;"&gt;  &lt;/div&gt;&lt;p style="text-align: justify;" class="MsoNormal"&gt;When you initialize java bean (i.e. entity) from the load method, you can only access the properties of the java bean, for the first time, with in transactional context in which it was initialized.&lt;br /&gt;&lt;/p&gt;&lt;p style="text-align: justify;" class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="text-align: justify;" class="MsoNormal"&gt;When you try to access various properties outside of the transactional context that has been already committed, you will get &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_17"&gt;LazyInitializationException&lt;/span&gt;, as hibernate no longer has valid transactional context to use and hit the database.&lt;/p&gt;&lt;p style="text-align: justify;" class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="text-align: justify;"&gt;  &lt;/div&gt;&lt;p style="text-align: justify;" class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;&lt;div style="text-align: justify;"&gt;  &lt;/div&gt;&lt;p style="text-align: justify;" class="MsoNormal"&gt;So below code will fail and throw &lt;b style=""&gt;&lt;i style=""&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_18"&gt;LazyInitializationException&lt;/span&gt; – Could not initialize proxy – no session&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style="text-align: justify;" class="MsoNormal"&gt;&lt;br /&gt;&lt;b style=""&gt;&lt;i style=""&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;&lt;div style="text-align: justify;"&gt;  &lt;/div&gt;&lt;p style="text-align: justify;" class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;&lt;div style="text-align: justify;"&gt;  &lt;/div&gt;&lt;p class="MsoNormal" style="background: rgb(250, 250, 250) none repeat scroll 0% 0%; line-height: 16.8pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; text-align: justify;"&gt;&lt;span style=";font-family:&amp;quot;;font-size:8;"&gt;session.&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_19"&gt;beginTransaction&lt;/span&gt;();&lt;br /&gt;User user=(User)session.load(User.class, new Long(1));&lt;br /&gt;session.getTransaction().commit();&lt;br /&gt;System.out.println(user.getPassword());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="text-align: justify;"&gt;  &lt;/div&gt;&lt;p style="text-align: justify;" class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;&lt;div style="text-align: justify;"&gt;  &lt;/div&gt;&lt;p style="text-align: justify;" class="MsoNormal"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;b style=""&gt;So, big thing to understand from the load method is, you&lt;/b&gt; &lt;b style=""&gt;can’t really use loaded &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_20"&gt;JavaBean&lt;/span&gt; after the transaction is committed, whereas, you can use get method, because all the properties of the &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_21"&gt;JavaBean&lt;/span&gt; has been initialized right away&lt;/b&gt; &lt;/p&gt;&lt;div style="text-align: justify;"&gt;  &lt;/div&gt;&lt;div style="text-align: justify;"&gt;  &lt;/div&gt;&lt;p style="text-align: justify;" class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;&lt;div style="text-align: justify;"&gt;  &lt;/div&gt;&lt;p style="text-align: justify;" class="MsoNormal"&gt;Now let’s us talk about one more difference. What happens when you provide a primary key that &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_22"&gt;doesn&lt;/span&gt;’t exists in the database? Well, with the get method, it will simply return null object, which is no big deal, I can simply put a null check in my &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_23"&gt;DAO&lt;/span&gt; class method.&lt;/p&gt;&lt;p style="text-align: justify;" class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="text-align: justify;"&gt;  &lt;/div&gt;&lt;p style="text-align: justify;" class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;&lt;div style="text-align: justify;"&gt;  &lt;/div&gt;&lt;p style="text-align: justify;" class="MsoNormal"&gt;But with the load method, again it will not create any problem when you an invalid primary key. Does that mean, it will return a null object or what? Well, the answer is simply NO.&lt;span style=""&gt;  &lt;/span&gt;You will run into problem when you try to access a property of that instance.&lt;/p&gt;&lt;div style="text-align: justify;"&gt;  &lt;/div&gt;&lt;p style="text-align: justify;" class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;&lt;div style="text-align: justify;"&gt;  &lt;/div&gt;&lt;p style="text-align: justify;" class="MsoNormal"&gt;So after comparing load and get methods, you will ask when to use load ()? And when to use get ()?&lt;span style=""&gt;  &lt;/span&gt;Let’s see….&lt;/p&gt;&lt;div style="text-align: justify;"&gt;  &lt;/div&gt;&lt;p style="text-align: justify;" class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;&lt;div style="text-align: justify;"&gt;  &lt;/div&gt;&lt;p style="text-align: justify;" class="MsoNormal"&gt;Use get (&lt;/p&gt;&lt;div style="text-align: justify;"&gt;  &lt;/div&gt;&lt;ul style="text-align: justify;"&gt;&lt;li&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family:times new roman;"&gt;If you ever want to use &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_24"&gt;JavaBean&lt;/span&gt; properties even after transaction has been committed. And quite frankly, that tends to be most of the time. For example, if you load a User instance in a &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_25"&gt;Servlet&lt;/span&gt;, and you want to pass that instance to a Java Server Page for display purposes, you'd need to use the get method, otherwise, you'd have a &lt;/span&gt;&lt;b  style="font-family:times new roman;"&gt;&lt;i style=""&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_26"&gt;LazyInitializationException&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;span style="font-family:times new roman;"&gt; in your &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_27"&gt;JSP&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li  style="font-family:times new roman;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=""&gt;&lt;span style="font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; font-size-adjust: none; font-stretch: normal;font-size:7;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;If you are not sure that entity with the given primary key is exists or not&lt;/li&gt;&lt;/ul&gt;&lt;div style="text-align: justify;"&gt;      &lt;/div&gt;&lt;p style="text-align: justify;" class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;&lt;div style="text-align: justify;"&gt;  &lt;/div&gt;&lt;p style="text-align: justify;" class="MsoNormal"&gt;Use load ()&lt;/p&gt;&lt;div style="text-align: justify;"&gt;  &lt;/div&gt;&lt;ul style="margin-top: 0in; text-align: justify;" type="disc"&gt;&lt;li class="MsoNormal"&gt;If      your goal is transactional and you want to access &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_28"&gt;JavaBean&lt;/span&gt; properties with      in the specified transaction&lt;/li&gt;&lt;li class="MsoNormal"&gt;If you      want to ensure that &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_29"&gt;JavaBean&lt;/span&gt; is sync with the database, you will use load      method. Because it will ensure that fields are loaded in from the database      and not from the &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_30"&gt;JVM&lt;/span&gt; on which you are running&lt;/li&gt;&lt;li class="MsoNormal"&gt;If you      are absolutely sure that the entity you are searching is already present      in database.&lt;/li&gt;&lt;/ul&gt;&lt;div style="text-align: justify;"&gt;  &lt;/div&gt;&lt;p style="text-align: justify;" class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;&lt;div style="text-align: justify;"&gt;  &lt;/div&gt;&lt;p style="text-align: justify;" class="MsoNormal"&gt;I hope above explanation will help you to understand differences between both functions and their actual usage. &lt;/p&gt;&lt;div style="text-align: justify;"&gt;  &lt;/div&gt;&lt;p style="text-align: justify;" class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;&lt;div style="text-align: justify;"&gt;  &lt;/div&gt;&lt;p style="text-align: justify;" class="MsoNormal"&gt;With good understanding of these two functions will surely help you in avoiding &lt;b style=""&gt;&lt;i style=""&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_31"&gt;LazyInitializationException&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;</description><link>http://chintanpparekh.blogspot.com/2009/05/normal-0-false-false-false.html</link><author>noreply@blogger.com (Chintan Parekh)</author><thr:total>5</thr:total></item></channel></rss>