{"id":323,"date":"2010-11-25T13:13:00","date_gmt":"2010-11-25T13:13:00","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/2012\/10\/jax-ws-with-spring-and-maven-tutorial.html"},"modified":"2012-10-21T19:21:35","modified_gmt":"2012-10-21T19:21:35","slug":"jaxws-with-spring-and-maven-tutorial","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2010\/11\/jaxws-with-spring-and-maven-tutorial.html","title":{"rendered":"JAX\u2013WS with Spring and Maven Tutorial"},"content":{"rendered":"<p><a href=\"http:\/\/www.springsource.org\/\">Spring<\/a> framework provides remoting support for web services via <a href=\"https:\/\/jax-ws.dev.java.net\/\">JAX\u2013WS<\/a>, in fact, as stated in <a href=\"http:\/\/www.springsource.org\/\">Spring<\/a> <a href=\"http:\/\/static.springsource.org\/spring\/docs\/2.5.x\/reference\/remoting.html\">reference documentation<\/a>, there are three ways of exposing <a href=\"http:\/\/www.springsource.org\/\">Spring<\/a> POJO services as a <a href=\"https:\/\/jax-ws.dev.java.net\/\">JAX\u2013WS<\/a> web services :<\/p>\n<ol>\n<li>Exposing <a href=\"http:\/\/www.oracle.com\/technetwork\/java\/index-jsp-135475.html\">Servlet<\/a> \u2013 based web services (suitable for Java EE 5 environments)<\/li>\n<li>Exporting standalone web services (suitable when utilizing Sun&#8217;s JDK 1.6 build\u2013in <a href=\"https:\/\/jax-ws.dev.java.net\/\">JAX\u2013WS<\/a> provider)<\/li>\n<li>Exporting web services using the <a href=\"https:\/\/jax-ws.dev.java.net\/\">JAX\u2013WS<\/a> RI&#8217;s <a href=\"http:\/\/www.springsource.org\/\">Spring<\/a> support (similar to the standalone approach, but this time in a <a href=\"http:\/\/www.oracle.com\/technetwork\/java\/index-jsp-135475.html\">Servlet<\/a> environment. Suitable for non \u2013 Java EE environments such as <a href=\"http:\/\/tomcat.apache.org\/\">Tomcat<\/a>, embedding the <a href=\"https:\/\/jax-ws.dev.java.net\/\">JAX\u2013WS<\/a> RI as part of the web application)<\/li>\n<\/ol>\n<p>Selecting one of the three approaches mentioned above depends mainly on your execution environment. Having said that, we will show you how to setup and expose a simple <a href=\"http:\/\/www.springsource.org\/\">Spring<\/a> service using all of the above approaches.<\/p>\n<p>Our preferred development environment is <a href=\"http:\/\/www.eclipse.org\/\">Eclipse<\/a>, so as a prerequisite you must have <a href=\"http:\/\/www.eclipse.org\/\">Eclipse<\/a> with <a href=\"http:\/\/maven.apache.org\/\">Maven<\/a> support installed. The installation of <a href=\"http:\/\/maven.apache.org\/\">Maven<\/a> plugin for <a href=\"http:\/\/www.eclipse.org\/\">Eclipse<\/a> is out of the scope of this tutorial and will not be discussed. Nevertheless you will need the following components :<\/p>\n<ol>\n<li><a href=\"http:\/\/www.eclipse.org\/\">Eclipse<\/a> from <a href=\"http:\/\/www.eclipse.org\/downloads\/\">here<\/a><\/li>\n<li><a href=\"http:\/\/maven.apache.org\/\">Maven<\/a> Plugin for <a href=\"http:\/\/www.eclipse.org\/\">Eclipse<\/a> from <a href=\"http:\/\/maven.apache.org\/eclipse-plugin.html\">here<\/a><\/li>\n<\/ol>\n<p>We will be using <a href=\"http:\/\/www.eclipse.org\/\">Eclipse<\/a> Galileo, \u201em2eclipse\u201c <a href=\"http:\/\/maven.apache.org\/\">Maven<\/a> Integration for <a href=\"http:\/\/www.eclipse.org\/\">Eclipse<\/a> Plugin version 0.10.0 and <a href=\"http:\/\/www.springsource.org\/\">Spring<\/a> version 3.0.1 for this tutorial.<\/p>\n<p>Lets begin,<\/p>\n<ol>\n<li>Create a new Maven project, go to File ? Project ? Maven ? Maven Project<\/li>\n<li>In the \u201eSelect project name and location\u201c page of the wizard, make sure that \u201eCreate a simple project (skip archetype selection)\u201c option is <strong>unchecked<\/strong>, hit \u201eNext\u201c to continue with default values<\/li>\n<li>In the \u201eSelect an Archetype\u201c page of the wizard, select \u201eNexus Indexer\u201c at the \u201eCatalog\u201c drop down list and after the archetypes selection area is refreshed, select the \u201ewebapp-javaee6\u201c archetype from \u201eorg.codehaus.mojo.archetypes\u201c to use. You can use the \u201efilter\u201c text box to narrow search results. Hit \u201eNext\u201c to continue<\/li>\n<li>In the \u201eEnter an artifact id\u201c page of the wizard, you can define the name and main package of your project. We will set the \u201eGroup Id\u201c variable to \u201ecom.javacodegeeks\u201c and the \u201eArtifact Id\u201c variable to \u201ejaxwsspring\u201c. The aforementioned selections compose the main project package as \u201ecom.javacodegeeks.jaxwsspring \u201c and the project name as \u201ejaxwsspring\u201c. Hit \u201eFinish\u201c to exit the wizard and to create your project<\/li>\n<\/ol>\n<p>Let&#8217;s recap a few things about the <a href=\"http:\/\/maven.apache.org\/\">Maven<\/a> Web project structure<\/p>\n<ol>\n<li>\/src\/main\/java folder contains source files for the dynamic content of the application<\/li>\n<li>\/src\/test\/java folder contains all source files for unit tests<\/li>\n<li>\/src\/main\/webapp folder contains essential files for creating a valid web application, e.g. \u201eweb.xml\u201c<\/li>\n<li>\/target folder contains the compiled and packaged deliverables<\/li>\n<li>The \u201epom.xml\u201c is the project object model (POM) file. The single file that contains all project related configuration.<\/li>\n<\/ol>\n<p>One thing to notice here is that we have chosen to utilize the <i><strong>Java EE6<\/strong><\/i> compatible <a href=\"http:\/\/maven.apache.org\/\">Maven<\/a> project archetype. Our selection is made on purpose so as to be easy to demonstrate all available approaches mentioned above. Nevertheless you can follow this tutorial and expose your <a href=\"http:\/\/www.springsource.org\/\">Spring<\/a> services as <a href=\"https:\/\/jax-ws.dev.java.net\/\">JAX\u2013WS<\/a> services even if you utilize a different environment (such as a standalone <a href=\"http:\/\/www.oracle.com\/technetwork\/java\/index-jsp-135475.html\">Servlet<\/a> environment e.g. Apache <a href=\"http:\/\/tomcat.apache.org\/\">Tomcat<\/a> or a Java EE 5 compatible application server e.g. <a href=\"http:\/\/www.jboss.org\/\">JBoss<\/a> Application Server).<\/p>\n<p>In order to properly use <a href=\"http:\/\/www.springsource.org\/\">Spring<\/a> at runtime, we must provide all necessary libraries to the web application. Open the graphical editor of your \u201epom.xml\u201c and perform the following changes :<\/p>\n<ol>\n<li>Locate the \u201eProperties\u201c section at the \u201eOverview\u201c page of the POM editor and perform the following changes :<\/li>\n<ul>\n<li>Create a new property with name <strong>org.springframework.version<\/strong> and value <strong>3.0.1.RELEASE<\/strong>&nbsp;<\/li>\n<\/ul>\n<li>Navigate to the \u201eDependencies\u201c page of the POM editor and create the following dependencies (you should fill the \u201eGroupId\u201c, \u201eArtifact Id\u201c and \u201eVersion\u201c fields of the \u201eDependency Details\u201c section at that page) :<\/li>\n<ul>\n<li>Group Id : <strong>org.springframework<\/strong> Artifact Id : <strong>spring-web<\/strong> Version : <strong>${org.springframework.version}<\/strong><\/li>\n<\/ul>\n<\/ol>\n<p>As you can see <a href=\"http:\/\/maven.apache.org\/\">Maven<\/a> manages library dependencies declaratively. A local repository is created (by default under {user_home}\/.m2 folder) and all required libraries are downloaded and placed there from public repositories. Furthermore intra \u2013 library dependencies are automatically resolved and manipulated.<\/p>\n<p>The next step is to provide hooks for the web application so as to load the <a href=\"http:\/\/www.springsource.org\/\">Spring<\/a> context upon startup.<\/p>\n<p>Create a \u201eWEB-INF \/web.xml\u201c file under \/src\/main\/webapp folder and add the following :<\/p>\n<pre class=\"brush: xml\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\r\n&lt;web-app version=\"2.5\" xmlns=\"http:\/\/java.sun.com\/xml\/ns\/javaee\"\r\n xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"\r\n xsi:schemaLocation=\"http:\/\/java.sun.com\/xml\/ns\/javaee http:\/\/java.sun.com\/xml\/ns\/javaee\/web-app_2_5.xsd\"&gt;\r\n &lt;display-name&gt;jaxwsspring&lt;\/display-name&gt;\r\n &lt;session-config&gt;\r\n  &lt;session-timeout&gt;30&lt;\/session-timeout&gt;\r\n &lt;\/session-config&gt;\r\n &lt;listener&gt;\r\n  &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;\/listener-class&gt;\r\n &lt;\/listener&gt;\r\n &lt;welcome-file-list&gt;\r\n  &lt;welcome-file&gt;index.jsp&lt;\/welcome-file&gt;\r\n &lt;\/welcome-file-list&gt;\r\n&lt;\/web-app&gt;\r\n<\/pre>\n<p>Now lets create the applicationContext.xml file that will drive <a href=\"http:\/\/www.springsource.org\/\">Spring<\/a> container. Create the file under \/src\/main\/webapp\/WEB-INF directory. An example \u201eapplicationContext.xml\u201c is presented below :<\/p>\n<pre class=\"brush: xml\">&lt;beans xmlns=\"http:\/\/www.springframework.org\/schema\/beans\"\r\n xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" xmlns:p=\"http:\/\/www.springframework.org\/schema\/p\"\r\n xmlns:aop=\"http:\/\/www.springframework.org\/schema\/aop\" xmlns:context=\"http:\/\/www.springframework.org\/schema\/context\"\r\n xmlns:jee=\"http:\/\/www.springframework.org\/schema\/jee\" xmlns:tx=\"http:\/\/www.springframework.org\/schema\/tx\"\r\n xmlns:task=\"http:\/\/www.springframework.org\/schema\/task\"\r\n xsi:schemaLocation=\"\r\n   http:\/\/www.springframework.org\/schema\/aop http:\/\/www.springframework.org\/schema\/aop\/spring-aop-3.0.xsd\r\n   http:\/\/www.springframework.org\/schema\/beans http:\/\/www.springframework.org\/schema\/beans\/spring-beans-3.0.xsd\r\n   http:\/\/www.springframework.org\/schema\/context http:\/\/www.springframework.org\/schema\/context\/spring-context-3.0.xsd\r\n   http:\/\/www.springframework.org\/schema\/jee http:\/\/www.springframework.org\/schema\/jee\/spring-jee-3.0.xsd\r\n   http:\/\/www.springframework.org\/schema\/tx http:\/\/www.springframework.org\/schema\/tx\/spring-tx-3.0.xsd\r\n   http:\/\/www.springframework.org\/schema\/task http:\/\/www.springframework.org\/schema\/task\/spring-task-3.0.xsd\"&gt;\r\n\r\n &lt;context:component-scan base-package=\"com.javacodegeeks.jaxwsspring\" \/&gt;\r\n\r\n&lt;\/beans&gt;\r\n<\/pre>\n<p>Things to notice here :<\/p>\n<ol>\n<li>Change the base-package attribute of the context:component-scan element to whatever is the base package of your project so as to be scanned for <a href=\"http:\/\/www.springsource.org\/\">Spring<\/a> components<\/li>\n<\/ol>\n<p>Lets create now a \u201cgreeting\u201d <a href=\"http:\/\/www.springsource.org\/\">Spring<\/a> service. Create a sub \u2013 package named \u201cservices\u201d under your main package and place the \u201cGreetingService\u201d class there. An example \u201cgreeting\u201d service is shown below :<\/p>\n<pre class=\"brush: java\">package com.javacodegeeks.jaxwsspring.services;\r\n\r\nimport org.springframework.stereotype.Service;\r\n\r\n@Service(\"greetingService\")\r\npublic class GreetingService {\r\n\r\n public String sayHello() {\r\n  return \"Hello from Greeting Service\";\r\n }\r\n \r\n}\r\n<\/pre>\n<p><a href=\"https:\/\/jax-ws.dev.java.net\/\">JAX\u2013WS<\/a> requires working with dedicated endpoint classes. If an existing service needs to be exported, a wrapper class is the simplest <a href=\"https:\/\/jax-ws.dev.java.net\/\">JAX\u2013WS<\/a> compliant way. Lets create now a \u201cgreeting\u201d endpoint class. Create a sub \u2013 package named \u201cendpoints\u201d under your main package and place the \u201cGreetingServiceEndpoint\u201d class there. An example \u201cgreeting\u201d endpoint class is shown below :<\/p>\n<pre class=\"brush: java\">package com.javacodegeeks.jaxwsspring.endpoints;\r\n\r\nimport javax.jws.WebMethod;\r\nimport javax.jws.WebService;\r\n\r\nimport org.springframework.beans.factory.annotation.Autowired;\r\n\r\nimport com.javacodegeeks.jaxwsspring.services.GreetingService;\r\n\r\n@WebService(serviceName=\"GreetingService\")\r\npublic class GreetingServiceEndpoint {\r\n\r\n @Autowired\r\n private GreetingService greetingService;\r\n \r\n @WebMethod\r\n public String sayHello() {\r\n  return greetingService.sayHello();\r\n }\r\n \r\n}\r\n<\/pre>\n<p>As you can see this is a <a href=\"https:\/\/jax-ws.dev.java.net\/\">JAX\u2013WS<\/a> compliant \u201cgreeting\u201d service implementation that simply delegates to the \u201cGreetingService\u201d implementation. This is the class that will be registered with the <a href=\"https:\/\/jax-ws.dev.java.net\/\">JAX\u2013WS<\/a> engine. In the case of a Java EE 5 server (the <a href=\"http:\/\/www.oracle.com\/technetwork\/java\/index-jsp-135475.html\">Servlet<\/a> \u2013 based web services approach), the web service engine manages the lifecycle of instances of the endpoint class. In the other two cases, the endpoint instances are defined and managed as <a href=\"http:\/\/www.springsource.org\/\">Spring<\/a> beans themselves so their lifecycle will be up to the <a href=\"http:\/\/www.springsource.org\/\">Spring<\/a> application context.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p><a href=\"http:\/\/www.springsource.org\/\">Spring<\/a> provides a convenient base class for <a href=\"https:\/\/jax-ws.dev.java.net\/\">JAX\u2013WS<\/a> <a href=\"http:\/\/www.oracle.com\/technetwork\/java\/index-jsp-135475.html\">Servlet<\/a> endpoint implementations \u2013  \u201cSpringBeanAutowiringSupport\u201d. To expose our \u201cGreetingService\u201d as a <a href=\"http:\/\/www.oracle.com\/technetwork\/java\/index-jsp-135475.html\">Servlet<\/a> based web service we must proceed as follows : <\/p>\n<ol>\n<li>Modify our \u201cGreetingServiceEndpoint\u201d class to extend Spring&#8217;s \u201cSpringBeanAutowiringSupport\u201d class. That way the <i><strong>@Autowired<\/strong><\/i> annotation will be honored and Spring&#8217;s IoC container will be able to inject the actual \u201cgreeting\u201d service instance to our endpoint class for delegating invocations properly.<\/li>\n<li>Our \u201cGreetingServiceEndpoint\u201d needs to run in the same web application as the <a href=\"http:\/\/www.springsource.org\/\">Spring<\/a> context to allow for access to Spring&#8217;s facilities. This is the case by default in Java EE 5 environments, using the standard contract for <a href=\"https:\/\/jax-ws.dev.java.net\/\">JAX\u2013WS<\/a> <a href=\"http:\/\/www.oracle.com\/technetwork\/java\/index-jsp-135475.html\">Servlet<\/a> endpoint deployment.<\/li>\n<li>The endpoint is the class registered with the server\u2013side <a href=\"https:\/\/jax-ws.dev.java.net\/\">JAX\u2013WS<\/a> implementation. In the case of a Java EE 5 server, this would simply be defined as a <a href=\"http:\/\/www.oracle.com\/technetwork\/java\/index-jsp-135475.html\">Servlet<\/a> in \u201cweb.xml\u201d, with the server detecting that this is a <a href=\"https:\/\/jax-ws.dev.java.net\/\">JAX\u2013WS<\/a> endpoint and reacting accordingly. The <a href=\"http:\/\/www.oracle.com\/technetwork\/java\/index-jsp-135475.html\">Servlet<\/a> name usually needs to match the specified web service service name.<\/li>\n<\/ol>\n<p>Having the above in mind alter your endpoint class as shown below :<\/p>\n<pre class=\"brush: java\">package com.javacodegeeks.jaxwsspring.endpoints;\r\n\r\nimport javax.jws.WebMethod;\r\nimport javax.jws.WebService;\r\n\r\nimport org.springframework.beans.factory.annotation.Autowired;\r\nimport org.springframework.web.context.support.SpringBeanAutowiringSupport;\r\n\r\nimport com.javacodegeeks.jaxwsspring.services.GreetingService;\r\n\r\n@WebService(serviceName=\"GreetingService\")\r\npublic class GreetingServiceEndpoint extends SpringBeanAutowiringSupport {\r\n\r\n @Autowired\r\n private GreetingService greetingService;\r\n \r\n @WebMethod\r\n public String sayHello() {\r\n  return greetingService.sayHello();\r\n }\r\n \r\n}\r\n<\/pre>\n<p>Finally add to your \u201cweb.xml\u201d the following <a href=\"http:\/\/www.oracle.com\/technetwork\/java\/index-jsp-135475.html\">Servlet<\/a> declaration :<\/p>\n<pre class=\"brush: xml\">&lt;servlet&gt;  \r\n   &lt;servlet-name&gt;GreetingService&lt;\/servlet-name&gt;  \r\n   &lt;servlet-class&gt;  \r\n      com.javacodegeeks.jaxwsspring.endpoints.GreetingServiceEndpoint\r\n   &lt;\/servlet-class&gt;  \r\n&lt;\/servlet&gt;  \r\n  \r\n&lt;servlet-mapping&gt;  \r\n   &lt;servlet-name&gt;GreetingService&lt;\/servlet-name&gt;  \r\n   &lt;url-pattern&gt;\/GreetingService&lt;\/url-pattern&gt;  \r\n&lt;\/servlet-mapping&gt;  \r\n<\/pre>\n<p>To build the application right click on your project ? Run As ? Maven package<\/p>\n<p>To deploy the web application just copy the \u201e.war\u201c file from the \u201etarget\u201c directory to your Java EE 5 server, web application deploy folder. For the purpose of this tutorial we are going to deploy our web application to a <a href=\"http:\/\/www.jboss.org\/\">JBoss<\/a> 5.1.0 Application Server.<\/p>\n<p>To launch the application point your browser to the following address<\/p>\n<p>http:\/\/localhost:8080\/jaxwsspring\/<\/p>\n<p>If all went well you should see your main web page displaying  the following :<\/p>\n<p>\u201cHelloWorld!\u201d<\/p>\n<p>Our web service address location should be at :<\/p>\n<p>http:\/\/localhost:8080\/jaxwsspring\/GreetingService<\/p>\n<p>We can view our web service WSDL if we point our browser to :<\/p>\n<p>http:\/\/localhost:8080\/jaxwsspring\/GreetingService?wsdl<\/p>\n<p>The result should be like the following :<\/p>\n<pre class=\"brush: xml\">&lt;definitions name=\"GreetingService\" targetNamespace=\"http:\/\/endpoints.jaxwsspring.javacodegeeks.com\/\"&gt;\r\n &lt;types&gt;\r\n  &lt;xs:schema targetNamespace=\"http:\/\/endpoints.jaxwsspring.javacodegeeks.com\/\" version=\"1.0\"&gt;\r\n   &lt;xs:element name=\"sayHello\" type=\"tns:sayHello\"\/&gt;\r\n   &lt;xs:element name=\"sayHelloResponse\" type=\"tns:sayHelloResponse\"\/&gt;\r\n   &lt;xs:complexType name=\"sayHello\"&gt;\r\n    &lt;xs:sequence\/&gt;\r\n   &lt;\/xs:complexType&gt;\r\n   &lt;xs:complexType name=\"sayHelloResponse\"&gt;\r\n    &lt;xs:sequence&gt;\r\n     &lt;xs:element minOccurs=\"0\" name=\"return\" type=\"xs:string\"\/&gt;\r\n    &lt;\/xs:sequence&gt;\r\n   &lt;\/xs:complexType&gt;\r\n  &lt;\/xs:schema&gt;\r\n &lt;\/types&gt;\r\n\r\n &lt;message name=\"GreetingServiceEndpoint_sayHello\"&gt;\r\n  &lt;part element=\"tns:sayHello\" name=\"sayHello\"\/&gt;\r\n &lt;\/message&gt;\r\n\r\n &lt;message name=\"GreetingServiceEndpoint_sayHelloResponse\"&gt;\r\n  &lt;part element=\"tns:sayHelloResponse\" name=\"sayHelloResponse\"\/&gt;\r\n &lt;\/message&gt;\r\n\r\n &lt;portType name=\"GreetingServiceEndpoint\"&gt;\r\n  &lt;operation name=\"sayHello\" parameterOrder=\"sayHello\"&gt;\r\n   &lt;input message=\"tns:GreetingServiceEndpoint_sayHello\"\/&gt;\r\n   &lt;output message=\"tns:GreetingServiceEndpoint_sayHelloResponse\"\/&gt;\r\n  &lt;\/operation&gt;\r\n &lt;\/portType&gt;\r\n\r\n &lt;binding name=\"GreetingServiceEndpointBinding\" type=\"tns:GreetingServiceEndpoint\"&gt;\r\n  &lt;soap:binding style=\"document\" transport=\"http:\/\/schemas.xmlsoap.org\/soap\/http\"\/&gt;\r\n  &lt;operation name=\"sayHello\"&gt;\r\n  &lt;soap:operation soapAction=\"\"\/&gt;\r\n   &lt;input&gt;\r\n    &lt;soap:body use=\"literal\"\/&gt;\r\n   &lt;\/input&gt;\r\n   &lt;output&gt;\r\n    &lt;soap:body use=\"literal\"\/&gt;\r\n   &lt;\/output&gt;\r\n  &lt;\/operation&gt;\r\n &lt;\/binding&gt;\r\n\r\n &lt;service name=\"GreetingService\"&gt;\r\n  &lt;port binding=\"tns:GreetingServiceEndpointBinding\" name=\"GreetingServiceEndpointPort\"&gt;\r\n   &lt;soap:address location=\"http:\/\/127.0.0.1:8080\/jaxwsspring\/GreetingService\"\/&gt;\r\n  &lt;\/port&gt;\r\n &lt;\/service&gt;\r\n&lt;\/definitions&gt;\r\n<\/pre>\n<p>Now that we have our web service definition we can use our favorite SOAP client \u2013 generate or implement one \u2013 to invoke operations of the \u201cgreeting\u201d web service. Accessing the web service is out of the scope of this tutorial and thus we will not discuss it further. Nevertheless we are going to provide an example request \u2013  response dialog when invoking the \u201csayHello\u201d operation of the \u201cGreetingService\u201d using our preferred tool for web service testing, <a href=\"http:\/\/sourceforge.net\/projects\/soapui\/\">soapUI<\/a><\/p>\n<p>The SOAP request as posted by the soapUI tool :<\/p>\n<pre class=\"brush: xml\">&lt;soapenv:Envelope xmlns:soapenv=\"http:\/\/schemas.xmlsoap.org\/soap\/envelope\/\" xmlns:end=\"http:\/\/endpoints.jaxwsspring.javacodegeeks.com\/\"&gt;\r\n   &lt;soapenv:Header\/&gt;\r\n   &lt;soapenv:Body&gt;\r\n      &lt;end:sayHello\/&gt;\r\n   &lt;\/soapenv:Body&gt;\r\n&lt;\/soapenv:Envelope&gt;\r\n<\/pre>\n<p>The relevant SOAP response as receieved from the \u201cgreeting\u201d web service :<\/p>\n<pre class=\"brush: xml\">&lt;env:Envelope xmlns:env=\"http:\/\/schemas.xmlsoap.org\/soap\/envelope\/\"&gt;\r\n   &lt;env:Header\/&gt;\r\n   &lt;env:Body&gt;\r\n      &lt;ns2:sayHelloResponse xmlns:ns2=\"http:\/\/endpoints.jaxwsspring.javacodegeeks.com\/\"&gt;\r\n         &lt;return&gt;Hello from Greeting Service&lt;\/return&gt;\r\n      &lt;\/ns2:sayHelloResponse&gt;\r\n   &lt;\/env:Body&gt;\r\n&lt;\/env:Envelope&gt;\r\n<\/pre>\n<p>As stated above, the built\u2013in <a href=\"https:\/\/jax-ws.dev.java.net\/\">JAX\u2013WS<\/a> provider that comes with Sun&#8217;s JDK 1.6 supports exposure of web services using the built\u2013in HTTP server that&#8217;s included in JDK 1.6 as well. Spring&#8217;s \u201cSimpleJaxWsServiceExporter\u201d detects all <i><strong>@WebService<\/strong><\/i> annotated beans in the <a href=\"http:\/\/www.springsource.org\/\">Spring<\/a> application context, exporting them through the default <a href=\"https:\/\/jax-ws.dev.java.net\/\">JAX\u2013WS<\/a> server (the JDK 1.6 HTTP server).<\/p>\n<p>In this scenario, the endpoint instances are defined and managed as <a href=\"http:\/\/www.springsource.org\/\">Spring<\/a> beans themselves; they will be registered with the <a href=\"https:\/\/jax-ws.dev.java.net\/\">JAX\u2013WS<\/a> engine but their lifecycle will be up to the <a href=\"http:\/\/www.springsource.org\/\">Spring<\/a> application context. This means that <a href=\"http:\/\/www.springsource.org\/\">Spring<\/a> functionality like explicit dependency injection may be applied to the endpoint instances. Of course, annotation-driven injection through <i><strong>@Autowired<\/strong><\/i> will work as well.<\/p>\n<p>To utilize this approach all we have to do is to declare our endpoint class as a <a href=\"http:\/\/www.springsource.org\/\">Spring<\/a> bean by annotating it with the <i><strong>@Service<\/strong><\/i> annotation. Additionally we must add the \u201cSimpleJaxWsServiceExporter\u201d bean declaration in our application context file as shown below :<\/p>\n<pre class=\"brush: java\">package com.javacodegeeks.jaxwsspring.endpoints;\r\n\r\nimport javax.jws.WebMethod;\r\nimport javax.jws.WebService;\r\n\r\nimport org.springframework.beans.factory.annotation.Autowired;\r\nimport org.springframework.stereotype.Service;\r\n\r\nimport com.javacodegeeks.jaxwsspring.services.GreetingService;\r\n\r\n@Service(\"greetingServiceEndpoint\")\r\n@WebService(serviceName=\"GreetingService\")\r\npublic class GreetingServiceEndpoint {\r\n\r\n @Autowired\r\n private GreetingService greetingService;\r\n \r\n @WebMethod\r\n public String sayHello() {\r\n  return greetingService.sayHello();\r\n }\r\n \r\n}\r\n<\/pre>\n<p>Things to notice here :<\/p>\n<ol>\n<li>The GreetingServiceEndpoint may derive from Spring&#8217;s \u201cSpringBeanAutowiringSupport\u201d but doesn&#8217;t have to since the endpoint is a fully Spring\u2013managed bean here<\/li>\n<\/ol>\n<pre class=\"brush: xml\">&lt;beans xmlns=\"http:\/\/www.springframework.org\/schema\/beans\"\r\n xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" xmlns:p=\"http:\/\/www.springframework.org\/schema\/p\"\r\n xmlns:aop=\"http:\/\/www.springframework.org\/schema\/aop\" xmlns:context=\"http:\/\/www.springframework.org\/schema\/context\"\r\n xmlns:jee=\"http:\/\/www.springframework.org\/schema\/jee\" xmlns:tx=\"http:\/\/www.springframework.org\/schema\/tx\"\r\n xmlns:task=\"http:\/\/www.springframework.org\/schema\/task\"\r\n xsi:schemaLocation=\"\r\n   http:\/\/www.springframework.org\/schema\/aop http:\/\/www.springframework.org\/schema\/aop\/spring-aop-3.0.xsd\r\n   http:\/\/www.springframework.org\/schema\/beans http:\/\/www.springframework.org\/schema\/beans\/spring-beans-3.0.xsd\r\n   http:\/\/www.springframework.org\/schema\/context http:\/\/www.springframework.org\/schema\/context\/spring-context-3.0.xsd\r\n   http:\/\/www.springframework.org\/schema\/jee http:\/\/www.springframework.org\/schema\/jee\/spring-jee-3.0.xsd\r\n   http:\/\/www.springframework.org\/schema\/tx http:\/\/www.springframework.org\/schema\/tx\/spring-tx-3.0.xsd\r\n   http:\/\/www.springframework.org\/schema\/task http:\/\/www.springframework.org\/schema\/task\/spring-task-3.0.xsd\"&gt;\r\n\r\n &lt;context:component-scan base-package=\"com.javacodegeeks.jaxwsspring\" \/&gt;\r\n\r\n &lt;bean class=\"org.springframework.remoting.jaxws.SimpleJaxWsServiceExporter\"&gt;\r\n  &lt;property name=\"baseAddress\" value=\"http:\/\/localhost:9999\/\" \/&gt;\r\n &lt;\/bean&gt;\r\n\r\n&lt;\/beans&gt;\r\n<\/pre>\n<p>Things to notice here :<\/p>\n<ol>\n<li>Change the base-package attribute of the context:component-scan element to whatever is the base package of your project so as to be scanned for <a href=\"http:\/\/www.springsource.org\/\">Spring<\/a> components<\/li>\n<li>You can change the \u201cbaseAddress\u201d property of \u201c SimpleJaxWsServiceExporter\u201d to fit your needs. The \u201cbaseAddress\u201d is the address under which all detected web services will be exported. The default \u201cbaseAddress\u201d is \u201chttp:\/\/localhost:8080\/\u201d<\/li>\n<\/ol>\n<p>To build the application right click on your project ? Run As ? Maven package<\/p>\n<p>To test the specific approach we are going to deploy our web application to an Apache <a href=\"http:\/\/tomcat.apache.org\/\">Tomcat<\/a> 6 server. Do not forget that we will be utilizing Sun&#8217;s JDK 1.6 build\u2013in <a href=\"https:\/\/jax-ws.dev.java.net\/\">JAX\u2013WS<\/a> provider; even though we are  operating in a <a href=\"http:\/\/www.oracle.com\/technetwork\/java\/index-jsp-135475.html\">Servlet<\/a> container. In this specific scenario we are using the <a href=\"http:\/\/www.oracle.com\/technetwork\/java\/index-jsp-135475.html\">Servlet<\/a> container just for launching the <a href=\"http:\/\/www.springsource.org\/\">Spring<\/a> application. Alternatively you could implement a Main class and launch the <a href=\"http:\/\/www.springsource.org\/\">Spring<\/a> application programmatically.<\/p>\n<p>To launch the application point your browser to the following address<\/p>\n<p>http:\/\/localhost:8080\/jaxwsspring\/<\/p>\n<p>If all went well you should see your main web page displaying  the following :<\/p>\n<p>\u201cHelloWorld!\u201d<\/p>\n<p>Our web service address location should be at :<\/p>\n<p>http:\/\/localhost:9999\/GreetingService<\/p>\n<p>We can view our web service WSDL if we point our browser to :<\/p>\n<p>http:\/\/localhost:9999\/GreetingService?wsdl<\/p>\n<p>Once again we can use the web service definition to generate and\/or implement a SOAP client so as to invoke operations of the \u201cgreeting\u201d web service. <\/p>\n<p>Sun&#8217;s <a href=\"https:\/\/jax-ws.dev.java.net\/\">JAX\u2013WS<\/a> RI, developed as part of the GlassFish project, ships <a href=\"http:\/\/www.springsource.org\/\">Spring<\/a> support as part of its <a href=\"https:\/\/jax-ws.dev.java.net\/\">JAX\u2013WS<\/a> Commons project. This allows for defining <a href=\"https:\/\/jax-ws.dev.java.net\/\">JAX\u2013WS<\/a> endpoints as Spring\u2013managed beans, similar to the standalone mode discussed in the previous section \u2013 but this time in a <a href=\"http:\/\/www.oracle.com\/technetwork\/java\/index-jsp-135475.html\">Servlet<\/a> environment. Note that this is not portable in a Java EE 5 environment; it is mainly intended for non-EE environments such as <a href=\"http:\/\/tomcat.apache.org\/\">Tomcat<\/a>, embedding the <a href=\"https:\/\/jax-ws.dev.java.net\/\">JAX\u2013WS<\/a> RI as part of the web application.<\/p>\n<p>The difference to the standard style of exporting Servlet\u2013based endpoints is that the lifecycle of the endpoint instances themselves will be managed by <a href=\"http:\/\/www.springsource.org\/\">Spring<\/a> here, and that there will be only one <a href=\"https:\/\/jax-ws.dev.java.net\/\">JAX\u2013WS<\/a> <a href=\"http:\/\/www.oracle.com\/technetwork\/java\/index-jsp-135475.html\">Servlet<\/a> defined in \u201cweb.xml\u201d. With the standard Java EE 5 style (as illustrated above), you&#8217;ll have one <a href=\"http:\/\/www.oracle.com\/technetwork\/java\/index-jsp-135475.html\">Servlet<\/a> definition per service endpoint, with each endpoint typically delegating to <a href=\"http:\/\/www.springsource.org\/\">Spring<\/a> beans.<\/p>\n<p>This last approach is <a href=\"http:\/\/www.springsource.org\/\">Spring<\/a> <i><strong>2.0<\/strong><\/i> specific, so prior altering any of our code we should change our project configuration a little. In particular we must remove the dependency for the <a href=\"http:\/\/www.springsource.org\/\">Spring<\/a> 3 libraries and add a new one to the <i><strong>jaxws-spring<\/strong><\/i> library. Open the graphical editor of your \u201epom.xml\u201c and perform the following changes :<\/p>\n<ol>\n<li>Locate the \u201eProperties\u201c section at the \u201eOverview\u201c page of the POM editor and remove the property with name <i><strong>org.springframework.version<\/strong><\/i> if exists &#8211; in case you followed this tutorial from the start<\/li>\n<li>Navigate to the \u201eDependencies\u201c page of the POM editor and create the following dependencies (you should fill the \u201eGroupId\u201c, \u201eArtifact Id\u201c and \u201eVersion\u201c fields of the \u201eDependency Details\u201c section at that page) :<\/li>\n<ul>\n<li>Group Id : <strong>org.jvnet.jax-ws-commons.spring<\/strong> Artifact Id : <strong>jaxws-spring<\/strong> Version : <strong>1.8<\/strong>&nbsp;<\/li>\n<\/ul>\n<ol><\/ol>\n<li>Since the time of this writing there is a dependency declaration flaw in the \u201cpom\u201d file of the latest version (<strong>1.8<\/strong>) of  <strong>jaxws-spring<\/strong> library. In particular an unnecessary dependency declaration for the <strong>2.1.2<\/strong> version of the <strong>jaxb-impl<\/strong> causes the code to break. To overcome this issue you must configure an exclusion for the specific version of the <strong>jaxb-impl<\/strong> library.  To do so, select the newly created dependency, locate the \u201cExclusions\u201d section of the editor&#8217;s page and create the exclusion as shown below :<\/li>\n<ul>\n<li>Group Id : <strong>com.sun.xml.bind<\/strong> Artifact Id : <strong>jaxb-impl<\/strong>&nbsp;<\/li>\n<\/ul>\n<ol><\/ol>\n<li>Additionally create another explicit dependency for the 2.1.6 version of the jaxb-impl library as  shown below :<\/li>\n<ul>\n<li>Group Id : <strong>com.sun.xml.bind<\/strong> Artifact Id : <strong>jaxb-impl<\/strong> Version : <strong>2.1.6<\/strong>&nbsp;<\/li>\n<\/ul>\n<ol><\/ol>\n<li>Last but not least we have to configure two new repositories in order for maven to be able to download the project dependences. Navigate to the \u201eRepositories\u201c page of the POM editor and create the following repositories :<\/li>\n<ul>\n<li>Id : <strong>download.java.net repo 1<\/strong> URL : <strong>http:\/\/download.java.net\/maven\/1\/<\/strong> Layout : <strong>legacy<\/strong>&nbsp;<\/li>\n<li>Id : <strong>download.java.net repo 2<\/strong> URL : <strong>http:\/\/download.java.net\/maven\/2\/&nbsp;<\/strong><\/li>\n<\/ul>\n<\/ol>\n<p>To utilize this approach we have to follow the steps described below :<\/p>\n<p>Locate the \u201cweb.xml\u201d file and alter it by defining the main <a href=\"https:\/\/jax-ws.dev.java.net\/\">JAX\u2013WS<\/a> <a href=\"http:\/\/www.oracle.com\/technetwork\/java\/index-jsp-135475.html\">Servlet<\/a> along with as many <a href=\"http:\/\/www.oracle.com\/technetwork\/java\/index-jsp-135475.html\">Servlet<\/a> mappings as necessary for the services we want to expose as web services; one <a href=\"http:\/\/www.oracle.com\/technetwork\/java\/index-jsp-135475.html\">Servlet<\/a> mapping per service. Thus for our specific test case we should add the following declarations:<\/p>\n<pre class=\"brush: xml\">&lt;servlet&gt;\r\n    &lt;servlet-name&gt;jaxws-servlet&lt;\/servlet-name&gt;\r\n    &lt;servlet-class&gt;com.sun.xml.ws.transport.http.servlet.WSSpringServlet&lt;\/servlet-class&gt;\r\n  &lt;\/servlet&gt;\r\n\r\n  &lt;servlet-mapping&gt;\r\n    &lt;servlet-name&gt;jaxws-servlet&lt;\/servlet-name&gt;\r\n    &lt;url-pattern&gt;\/GreetingService&lt;\/url-pattern&gt;\r\n  &lt;\/servlet-mapping&gt;\r\n<\/pre>\n<p>Alter \u201capplicationContext.xml\u201d file as shown below :<\/p>\n<pre class=\"brush: xml\">&lt;beans xmlns=\"http:\/\/www.springframework.org\/schema\/beans\"\r\n  xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"\r\n  xmlns:ws=\"http:\/\/jax-ws.dev.java.net\/spring\/core\"\r\n  xmlns:wss=\"http:\/\/jax-ws.dev.java.net\/spring\/servlet\"\r\n  xsi:schemaLocation=\"\r\n    http:\/\/www.springframework.org\/schema\/beans\r\n    http:\/\/www.springframework.org\/schema\/beans\/spring-beans-2.0.xsd\r\n    http:\/\/jax-ws.dev.java.net\/spring\/core\r\n    http:\/\/jax-ws.dev.java.net\/spring\/core.xsd\r\n    http:\/\/jax-ws.dev.java.net\/spring\/servlet\r\n    http:\/\/jax-ws.dev.java.net\/spring\/servlet.xsd\"&gt;\r\n\r\n  &lt;wss:binding url=\"\/GreetingService\"&gt;\r\n    &lt;wss:service&gt;\r\n      &lt;ws:service bean=\"#greetingService\" \/&gt;\r\n    &lt;\/wss:service&gt;\r\n  &lt;\/wss:binding&gt;\r\n\r\n  &lt;bean id=\"greetingService\" class=\"com.javacodegeeks.jaxwsspring.services.GreetingService\" \/&gt;\r\n\r\n&lt;\/beans&gt;\r\n<\/pre>\n<p>Things to notice here :<\/p>\n<ol>\n<li>This approach is <a href=\"http:\/\/www.springsource.org\/\">Spring<\/a> <strong>2.0<\/strong> specific, so a <a href=\"http:\/\/www.springsource.org\/\">Spring<\/a> <strong>2.0<\/strong> compatible \u201capplicationContext.xml\u201d file has been created. Notice that we have declared the \u201cgreeting\u201d <a href=\"http:\/\/www.springsource.org\/\">Spring<\/a> service bean directly in the \u201capplicationContext.xml\u201d file since the <i><strong>@Service<\/strong><\/i> annotation is not available in <a href=\"http:\/\/www.springsource.org\/\">Spring<\/a> <strong>2.0<\/strong>&nbsp;<\/li>\n<li>The <i><strong>wss:binding<\/strong><\/i> definition define what service is exposed to which part of the URL space. In the above code, it deploys the \u201cGreetingService\u201d on the \/GreetingService URL<\/li>\n<li>The <i><strong>ws:service<\/strong><\/i> definition realizes a web service instance. To its simplest form the bean attribute should be configured in order to delegate all invocations to the designated <a href=\"http:\/\/www.springsource.org\/\">Spring<\/a> bean. As you can see with this approach we can omit the creation of an \u201cendpoint\u201d class to proxy our <a href=\"http:\/\/www.springsource.org\/\">Spring<\/a> services.<\/li>\n<\/ol>\n<p>Finally we implement our \u201cGreetingService\u201d as shown below :<\/p>\n<pre class=\"brush: java\">package com.javacodegeeks.jaxwsspring.services;\r\n\r\nimport javax.jws.WebMethod;\r\nimport javax.jws.WebService;\r\nimport javax.jws.soap.SOAPBinding;\r\nimport javax.jws.soap.SOAPBinding.Style;\r\nimport javax.jws.soap.SOAPBinding.Use;\r\n\r\n@WebService(serviceName=\"GreetingService\")\r\n@SOAPBinding(style = Style.RPC, use = Use.LITERAL)\r\npublic class GreetingService {\r\n\r\n @WebMethod\r\n public String sayHello() {\r\n  return \"Hello from Greeting Service\";\r\n }\r\n \r\n}\r\n<\/pre>\n<p>Things to notice here :<\/p>\n<ol>\n<li>You should run the \u201c<strong>wsgen<\/strong>\u201d tool if you are using \u201c<i>Style.DOCUMENT<\/i>\u201d. \u201c<i>Style.RPC<\/i>\u201d is used only for demonstration purposes.<\/li>\n<li>The <i><strong>@Service<\/strong><\/i> annotation is not available in <a href=\"http:\/\/www.springsource.org\/\">Spring<\/a> <strong>2.0<\/strong> so we declare it directly in the \u201capplicationContext.xml\u201d file<\/li>\n<\/ol>\n<p>To build the application right click on your project ? Run As ? Maven package<\/p>\n<p>To test the specific approach we are going to deploy our web application to an Apache <a href=\"http:\/\/tomcat.apache.org\/\">Tomcat<\/a> 6 server. <\/p>\n<p>To launch the application point your browser to the following address<\/p>\n<p>http:\/\/localhost:8080\/jaxwsspring\/<\/p>\n<p>If all went well you should see your main web page displaying  the following :<\/p>\n<p>\u201cHelloWorld!\u201d<\/p>\n<p>Our web service address location should be at :<\/p>\n<p>http:\/\/localhost:8080\/jaxwsspring\/GreetingService<\/p>\n<p>We can view our web service WSDL if we point our browser to :<\/p>\n<p>http:\/\/localhost:8080\/jaxwsspring\/GreetingService?wsdl<\/p>\n<p>Once again we can use the web service definition to generate and\/or implement a SOAP client so as to invoke operations of the \u201cgreeting\u201d web service. <\/p>\n<p>Happy coding<\/p>\n<p>Justin<\/p>\n<div style=\"margin: 0px\"><strong><i>Related Articles :<\/i><\/strong><\/div>\n<ul>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2010\/05\/gwt-2-spring-3-jpa-2-hibernate-35.html\">GWT 2 Spring 3 JPA 2 Hibernate 3.5 Tutorial<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2010\/06\/gwt-spring-and-hibernate-enter-world-of.html\">GWT Spring and Hibernate enter the world of Data Grids<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2010\/06\/spring-3-hornetq-21-integration.html\">Spring 3 HornetQ 2.1 Integration Tutorial<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2010\/06\/spring-3-restful-web-services.html\">Spring 3 RESTful Web Services<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2010\/07\/gwt-2-spring-3-jpa-2-hibernate-35.html\">GWT 2 Spring 3 JPA 2 Hibernate 3.5 Tutorial \u2013 Eclipse and Maven 2 showcase<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Spring framework provides remoting support for web services via JAX\u2013WS, in fact, as stated in Spring reference documentation, there are three ways of exposing Spring POJO services as a JAX\u2013WS web services : Exposing Servlet \u2013 based web services (suitable for Java EE 5 environments) Exporting standalone web services (suitable when utilizing Sun&#8217;s JDK 1.6 &hellip;<\/p>\n","protected":false},"author":4,"featured_media":110,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[68,32,29,105,48,30,106],"class_list":["post-323","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-apache-maven","tag-apache-tomcat","tag-eclipse","tag-jax-ws","tag-jboss","tag-spring","tag-web-services"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>JAX\u2013WS with Spring and Maven Tutorial - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Spring framework provides remoting support for web services via JAX\u2013WS, in fact, as stated in Spring reference documentation, there are three ways of\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2010\/11\/jaxws-with-spring-and-maven-tutorial.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"JAX\u2013WS with Spring and Maven Tutorial - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Spring framework provides remoting support for web services via JAX\u2013WS, in fact, as stated in Spring reference documentation, there are three ways of\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2010\/11\/jaxws-with-spring-and-maven-tutorial.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2010-11-25T13:13:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2012-10-21T19:21:35+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/eclipse-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Byron Kiourtzoglou\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Byron Kiourtzoglou\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"19 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/11\\\/jaxws-with-spring-and-maven-tutorial.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/11\\\/jaxws-with-spring-and-maven-tutorial.html\"},\"author\":{\"name\":\"Byron Kiourtzoglou\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/9c0c8d27141b068173953202dd9aebeb\"},\"headline\":\"JAX\u2013WS with Spring and Maven Tutorial\",\"datePublished\":\"2010-11-25T13:13:00+00:00\",\"dateModified\":\"2012-10-21T19:21:35+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/11\\\/jaxws-with-spring-and-maven-tutorial.html\"},\"wordCount\":2640,\"commentCount\":11,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/11\\\/jaxws-with-spring-and-maven-tutorial.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/eclipse-logo.jpg\",\"keywords\":[\"Apache Maven\",\"Apache Tomcat\",\"Eclipse\",\"JAX-WS\",\"JBoss\",\"Spring\",\"Web Services\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/11\\\/jaxws-with-spring-and-maven-tutorial.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/11\\\/jaxws-with-spring-and-maven-tutorial.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/11\\\/jaxws-with-spring-and-maven-tutorial.html\",\"name\":\"JAX\u2013WS with Spring and Maven Tutorial - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/11\\\/jaxws-with-spring-and-maven-tutorial.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/11\\\/jaxws-with-spring-and-maven-tutorial.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/eclipse-logo.jpg\",\"datePublished\":\"2010-11-25T13:13:00+00:00\",\"dateModified\":\"2012-10-21T19:21:35+00:00\",\"description\":\"Spring framework provides remoting support for web services via JAX\u2013WS, in fact, as stated in Spring reference documentation, there are three ways of\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/11\\\/jaxws-with-spring-and-maven-tutorial.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/11\\\/jaxws-with-spring-and-maven-tutorial.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/11\\\/jaxws-with-spring-and-maven-tutorial.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/eclipse-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/eclipse-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/11\\\/jaxws-with-spring-and-maven-tutorial.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/enterprise-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"JAX\u2013WS with Spring and Maven Tutorial\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/9c0c8d27141b068173953202dd9aebeb\",\"name\":\"Byron Kiourtzoglou\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/45058c722c80f088c409be43e0f4be20dad81d55a7c9aefd75bab2e4253ae4e6?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/45058c722c80f088c409be43e0f4be20dad81d55a7c9aefd75bab2e4253ae4e6?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/45058c722c80f088c409be43e0f4be20dad81d55a7c9aefd75bab2e4253ae4e6?s=96&d=mm&r=g\",\"caption\":\"Byron Kiourtzoglou\"},\"description\":\"Byron is a master software engineer working in the IT and Telecom domains. He is an applications developer in a wide variety of applications\\\/services. He is currently acting as the team leader and technical architect for a proprietary service creation and integration platform for both the IT and Telecom industries in addition to a in-house big data real-time analytics solution. He is always fascinated by SOA, middleware services and mobile development. Byron is co-founder and Executive Editor at Java Code Geeks.\",\"sameAs\":[\"https:\\\/\\\/www.pivotalgamers.com\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/byron-kiourtzoglou-530ab222\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/byron-kiourtzoglou\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"JAX\u2013WS with Spring and Maven Tutorial - Java Code Geeks","description":"Spring framework provides remoting support for web services via JAX\u2013WS, in fact, as stated in Spring reference documentation, there are three ways of","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/2010\/11\/jaxws-with-spring-and-maven-tutorial.html","og_locale":"en_US","og_type":"article","og_title":"JAX\u2013WS with Spring and Maven Tutorial - Java Code Geeks","og_description":"Spring framework provides remoting support for web services via JAX\u2013WS, in fact, as stated in Spring reference documentation, there are three ways of","og_url":"https:\/\/www.javacodegeeks.com\/2010\/11\/jaxws-with-spring-and-maven-tutorial.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2010-11-25T13:13:00+00:00","article_modified_time":"2012-10-21T19:21:35+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/eclipse-logo.jpg","type":"image\/jpeg"}],"author":"Byron Kiourtzoglou","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Byron Kiourtzoglou","Est. reading time":"19 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2010\/11\/jaxws-with-spring-and-maven-tutorial.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2010\/11\/jaxws-with-spring-and-maven-tutorial.html"},"author":{"name":"Byron Kiourtzoglou","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/9c0c8d27141b068173953202dd9aebeb"},"headline":"JAX\u2013WS with Spring and Maven Tutorial","datePublished":"2010-11-25T13:13:00+00:00","dateModified":"2012-10-21T19:21:35+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2010\/11\/jaxws-with-spring-and-maven-tutorial.html"},"wordCount":2640,"commentCount":11,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2010\/11\/jaxws-with-spring-and-maven-tutorial.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/eclipse-logo.jpg","keywords":["Apache Maven","Apache Tomcat","Eclipse","JAX-WS","JBoss","Spring","Web Services"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2010\/11\/jaxws-with-spring-and-maven-tutorial.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2010\/11\/jaxws-with-spring-and-maven-tutorial.html","url":"https:\/\/www.javacodegeeks.com\/2010\/11\/jaxws-with-spring-and-maven-tutorial.html","name":"JAX\u2013WS with Spring and Maven Tutorial - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2010\/11\/jaxws-with-spring-and-maven-tutorial.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2010\/11\/jaxws-with-spring-and-maven-tutorial.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/eclipse-logo.jpg","datePublished":"2010-11-25T13:13:00+00:00","dateModified":"2012-10-21T19:21:35+00:00","description":"Spring framework provides remoting support for web services via JAX\u2013WS, in fact, as stated in Spring reference documentation, there are three ways of","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2010\/11\/jaxws-with-spring-and-maven-tutorial.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2010\/11\/jaxws-with-spring-and-maven-tutorial.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2010\/11\/jaxws-with-spring-and-maven-tutorial.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/eclipse-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/eclipse-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2010\/11\/jaxws-with-spring-and-maven-tutorial.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/enterprise-java"},{"@type":"ListItem","position":4,"name":"JAX\u2013WS with Spring and Maven Tutorial"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/9c0c8d27141b068173953202dd9aebeb","name":"Byron Kiourtzoglou","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/45058c722c80f088c409be43e0f4be20dad81d55a7c9aefd75bab2e4253ae4e6?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/45058c722c80f088c409be43e0f4be20dad81d55a7c9aefd75bab2e4253ae4e6?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/45058c722c80f088c409be43e0f4be20dad81d55a7c9aefd75bab2e4253ae4e6?s=96&d=mm&r=g","caption":"Byron Kiourtzoglou"},"description":"Byron is a master software engineer working in the IT and Telecom domains. He is an applications developer in a wide variety of applications\/services. He is currently acting as the team leader and technical architect for a proprietary service creation and integration platform for both the IT and Telecom industries in addition to a in-house big data real-time analytics solution. He is always fascinated by SOA, middleware services and mobile development. Byron is co-founder and Executive Editor at Java Code Geeks.","sameAs":["https:\/\/www.pivotalgamers.com\/","https:\/\/www.linkedin.com\/in\/byron-kiourtzoglou-530ab222"],"url":"https:\/\/www.javacodegeeks.com\/author\/byron-kiourtzoglou"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/323","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=323"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/323\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/110"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=323"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=323"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=323"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}