Commits

Micha Kops committed 2199462

initial import

Comments (0)

Files changed (6)

+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>com.hascode.tutorial</groupId>
+	<artifactId>ws</artifactId>
+	<version>0.0.1-SNAPSHOT</version>
+	<name>Book Lookup Web Service</name>
+	<description>hasCode.com Contract-First-Webservices Tutorial</description>
+	<packaging>war</packaging>
+
+	<repositories>
+		<repository>
+			<id>java.net2</id>
+			<name>Repository hosting the jee6 artifacts</name>
+			<url>http://download.java.net/maven/2</url>
+		</repository>
+	</repositories>
+	<pluginRepositories>
+		<pluginRepository>
+			<id>java.net2</id>
+			<name>Repository hosting the jee6 artifacts</name>
+			<url>http://download.java.net/maven/2</url>
+		</pluginRepository>
+	</pluginRepositories>
+	<dependencies>
+		<dependency>
+			<groupId>javax</groupId>
+			<artifactId>javaee-web-api</artifactId>
+			<version>6.0</version>
+			<scope>provided</scope>
+		</dependency>
+		<dependency>
+			<groupId>com.sun.xml.ws</groupId>
+			<artifactId>jaxws-rt</artifactId>
+			<version>2.2</version>
+		</dependency>
+	</dependencies>
+	<build>
+
+		<plugins>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-compiler-plugin</artifactId>
+				<version>2.0.2</version>
+				<configuration>
+					<source>1.6</source>
+					<target>1.6</target>
+				</configuration>
+			</plugin>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-war-plugin</artifactId>
+				<version>2.1.1</version>
+				<configuration>
+					<failOnMissingWebXml>false</failOnMissingWebXml>
+				</configuration>
+			</plugin>
+
+			<plugin>
+				<groupId>org.mortbay.jetty</groupId>
+				<artifactId>jetty-maven-plugin</artifactId>
+			</plugin>
+
+			<plugin>
+				<groupId>org.codehaus.mojo</groupId>
+				<artifactId>build-helper-maven-plugin</artifactId>
+				<executions>
+					<execution>
+						<id>add-source</id>
+						<phase>generate-sources</phase>
+						<goals>
+							<goal>add-source</goal>
+						</goals>
+						<configuration>
+							<sources>
+								<source>${basedir}/target/generated/src/main/java</source>
+							</sources>
+						</configuration>
+					</execution>
+				</executions>
+			</plugin>
+
+			<plugin>
+				<groupId>org.codehaus.mojo</groupId>
+				<artifactId>jaxws-maven-plugin</artifactId>
+				<version>1.12</version>
+				<configuration>
+					<wsdlDirectory>${basedir}/src/main/resources/wsdl</wsdlDirectory>
+					<packageName>com.hascode.tutorial.ws.service</packageName>
+					<keep>true</keep>
+					<sourceDestDir>${basedir}/target/generated/src/main/java</sourceDestDir>
+				</configuration>
+				<executions>
+					<execution>
+						<goals>
+							<goal>wsimport</goal>
+						</goals>
+					</execution>
+				</executions>
+			</plugin>
+		</plugins>
+		<finalName>bookService</finalName>
+		<pluginManagement>
+			<plugins>
+				<!--This plugin's configuration is used to store Eclipse m2e settings 
+					only. It has no influence on the Maven build itself. -->
+				<plugin>
+					<groupId>org.eclipse.m2e</groupId>
+					<artifactId>lifecycle-mapping</artifactId>
+					<version>1.0.0</version>
+					<configuration>
+						<lifecycleMappingMetadata>
+							<pluginExecutions>
+								<pluginExecution>
+									<pluginExecutionFilter>
+										<groupId>
+											org.codehaus.mojo
+										</groupId>
+										<artifactId>
+											jaxws-maven-plugin
+										</artifactId>
+										<versionRange>
+											[1.12,)
+										</versionRange>
+										<goals>
+											<goal>wsimport</goal>
+										</goals>
+									</pluginExecutionFilter>
+									<action>
+										<ignore></ignore>
+									</action>
+								</pluginExecution>
+								<pluginExecution>
+									<pluginExecutionFilter>
+										<groupId>
+											org.codehaus.mojo
+										</groupId>
+										<artifactId>
+											build-helper-maven-plugin
+										</artifactId>
+										<versionRange>
+											[1.7,)
+										</versionRange>
+										<goals>
+											<goal>add-source</goal>
+										</goals>
+									</pluginExecutionFilter>
+									<action>
+										<ignore></ignore>
+									</action>
+								</pluginExecution>
+							</pluginExecutions>
+						</lifecycleMappingMetadata>
+					</configuration>
+				</plugin>
+			</plugins>
+		</pluginManagement>
+	</build>
+</project>

src/main/java/com/hascode/tutorial/ws/service/BookServicePortImpl.java

+package com.hascode.tutorial.ws.service;
+
+import java.util.GregorianCalendar;
+
+import javax.jws.WebService;
+import javax.xml.datatype.DatatypeConfigurationException;
+import javax.xml.datatype.DatatypeFactory;
+
+@WebService(endpointInterface = "com.hascode.tutorial.ws.service.BookServicePortType")
+public class BookServicePortImpl implements BookServicePortType {
+
+	@Override
+	public BookServiceResponseType fetchBooks(
+			final BookServiceRequestType bookServiceRequest) {
+		final BookServiceResponseType response = new BookServiceResponseType();
+		for (int i = 0; i < bookServiceRequest.getLimit(); i++) {
+			final BookType book = new BookType();
+			book.setAuthor("Elvis " + i);
+			try {
+				book.setPublished(DatatypeFactory.newInstance()
+						.newXMLGregorianCalendar(
+								new GregorianCalendar(2011, 8, 14)));
+			} catch (DatatypeConfigurationException e) {
+			}
+			book.setTitle("Programming Java Edition #" + i);
+			response.getBook().add(book);
+		}
+		return response;
+	}
+
+}

src/main/resources/schema/bookService.xsd

+<?xml version="1.0" encoding="UTF-8"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.hascode.com/bookService/1.0" xmlns:tns="http://www.hascode.com/bookService/1.0" elementFormDefault="qualified">
+
+    <element name="BookServiceRequest"
+    	type="tns:BookServiceRequestType">
+    </element>
+    
+    <complexType name="BookServiceRequestType">
+    	<sequence>
+    		<element name="limit" type="int"></element>
+    	</sequence>
+    </complexType>
+    
+    <complexType name="BookServiceResponseType">
+    	<sequence>
+    		<element name="book" type="tns:BookType" maxOccurs="unbounded" minOccurs="0"></element>
+    	</sequence>
+    </complexType>
+
+    <element name="BookServiceResponse"
+    	type="tns:BookServiceResponseType">
+    </element>
+
+    <complexType name="BookType">
+    	<sequence>
+    		<element name="title" type="string" maxOccurs="1" minOccurs="1"></element>
+    		<element name="author" type="string" maxOccurs="1" minOccurs="1"></element>
+    		<element name="published" type="date" maxOccurs="1" minOccurs="1"></element>
+    	</sequence>
+    </complexType>
+</schema>

src/main/resources/wsdl/bookService.wsdl

+<?xml version="1.0" encoding="UTF-8"?>
+<wsdl:definitions name="bookService"
+	targetNamespace="http://www.hascode.com/bookService/1.0" xmlns:tns="http://www.hascode.com/bookService/1.0"
+	xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+	xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
+	<wsdl:types>
+		<xsd:schema targetNamespace="http://www.hascode.com/bookService/1.0">
+			<xsd:import schemaLocation="../schema/bookService.xsd"
+				namespace="http://www.hascode.com/bookService/1.0" />
+		</xsd:schema>
+	</wsdl:types>
+	<wsdl:message name="BookServiceRequest">
+		<wsdl:part name="BookServiceRequest" element="tns:BookServiceRequest" />
+	</wsdl:message>
+	<wsdl:message name="BookServiceResponse">
+		<wsdl:part name="BookServiceResponse" element="tns:BookServiceResponse" />
+	</wsdl:message>
+	<wsdl:portType name="BookServicePortType">
+		<wsdl:operation name="fetchBooks">
+			<wsdl:input name="BookServiceRequest" message="tns:BookServiceRequest" />
+			<wsdl:output name="BookServiceResponse" message="tns:BookServiceResponse" />
+		</wsdl:operation>
+	</wsdl:portType>
+	<wsdl:binding name="BookServiceBinding" type="tns:BookServicePortType">
+		<soap:binding style="document"
+			transport="http://schemas.xmlsoap.org/soap/http" />
+		<wsdl:operation name="fetchBooks">
+			<soap:operation style="document"
+				soapAction="http://www.hascode.com/bookService/fetchBooks" />
+			<wsdl:input name="BookServiceRequest">
+				<soap:body use="literal" />
+			</wsdl:input>
+			<wsdl:output name="BookServiceResponse">
+				<soap:body use="literal" />
+			</wsdl:output>
+		</wsdl:operation>
+	</wsdl:binding>
+	<wsdl:service name="BookService">
+		<wsdl:port name="BookServicePort" binding="tns:BookServiceBinding">
+			<soap:address location="/service/bookService" />
+		</wsdl:port>
+	</wsdl:service>
+</wsdl:definitions>

src/main/webapp/WEB-INF/sun-jaxws.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<endpoints xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime"
+	version="2.0">
+	<endpoint name="bookService"
+		implementation="com.hascode.tutorial.ws.service.BookServicePortImpl"
+		url-pattern="/bookService" />
+</endpoints>

src/main/webapp/WEB-INF/web.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<web-app xmlns="http://java.sun.com/xml/ns/javaee"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
+         version="3.0">
+    <session-config>
+        <session-timeout>
+            40
+        </session-timeout>
+    </session-config>
+    <listener>
+        <listener-class>
+            com.sun.xml.ws.transport.http.servlet.WSServletContextListener
+        </listener-class>
+    </listener>
+    <servlet>
+        <description>JAX-WS endpoint</description>
+        <display-name>The JAX-WS servlet</display-name>
+        <servlet-name>jaxws</servlet-name>
+        <servlet-class>com.sun.xml.ws.transport.http.servlet.WSServlet</servlet-class>
+    </servlet>
+    <servlet-mapping>
+        <servlet-name>jaxws</servlet-name>
+        <url-pattern>/bookService</url-pattern>
+    </servlet-mapping>
+</web-app>