Skip to content

Commit 3e4cfec

Browse files
committed
JAX-WS endpoint example
1 parent 5cbb204 commit 3e4cfec

21 files changed

+882
-0
lines changed

jaxws/jaxws-endpoint/pom.xml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<parent>
5+
<groupId>org.javaee7.jaxws</groupId>
6+
<artifactId>jaxws-samples</artifactId>
7+
<version>1.0-SNAPSHOT</version>
8+
<relativePath>../pom.xml</relativePath>
9+
</parent>
10+
<artifactId>jaxws-endpoint</artifactId>
11+
<packaging>war</packaging>
12+
<build>
13+
<finalName>jaxws-endpoint</finalName>
14+
<plugins>
15+
<plugin>
16+
<!-- wsgen for web service artifact generation -->
17+
<groupId>org.codehaus.mojo</groupId>
18+
<artifactId>jaxws-maven-plugin</artifactId>
19+
<version>1.11</version>
20+
<executions>
21+
<execution>
22+
<phase>process-classes</phase>
23+
<goals>
24+
<goal>wsgen</goal>
25+
</goals>
26+
<configuration>
27+
<sei>org.javaee7.jaxws.endpoint.EBookStoreImpl</sei>
28+
<genWsdl>true</genWsdl>
29+
<keep>true</keep>
30+
<verbose>true</verbose>
31+
<resourceDestDir>${basedir}/src/main/webapp/WEB-INF/wsdl</resourceDestDir>
32+
<sourceDestDir>${basedir}/src/main/java</sourceDestDir>
33+
</configuration>
34+
</execution>
35+
</executions>
36+
</plugin>
37+
</plugins>
38+
</build>
39+
</project>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package org.javaee7.jaxws.endpoint;
2+
3+
import java.util.ArrayList;
4+
import java.util.List;
5+
6+
/**
7+
*
8+
* @author Fermin Gallego
9+
*
10+
*/
11+
public class EBook {
12+
private String title;
13+
private int numPages;
14+
private double price;
15+
private List<String> notes;
16+
17+
public EBook() {
18+
super();
19+
}
20+
public String getTitle() {
21+
return title;
22+
}
23+
public void setTitle(String title) {
24+
this.title = title;
25+
}
26+
public int getNumPages() {
27+
return numPages;
28+
}
29+
public void setNumPages(int numPages) {
30+
this.numPages = numPages;
31+
}
32+
public double getPrice() {
33+
return price;
34+
}
35+
public void setPrice(double price) {
36+
this.price = price;
37+
}
38+
public List<String> getNotes() {
39+
if (notes == null) {
40+
notes = new ArrayList<String>();
41+
}
42+
return notes;
43+
}
44+
public void setNotes(List<String> notes) {
45+
this.notes = notes;
46+
}
47+
48+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package org.javaee7.jaxws.endpoint;
2+
3+
import java.util.List;
4+
5+
import javax.jws.WebMethod;
6+
import javax.jws.WebService;
7+
8+
/**
9+
*
10+
* @author Fermin Gallego
11+
*
12+
*/
13+
@WebService
14+
public interface EBookStore {
15+
@WebMethod
16+
public String welcomeMessage(String name);
17+
@WebMethod
18+
public List<String> findEBooks(String text);
19+
@WebMethod
20+
public EBook takeBook(String title);
21+
@WebMethod
22+
public void saveBook(EBook eBook);
23+
@WebMethod
24+
public EBook addAppendix(EBook eBook,int appendixPages);
25+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package org.javaee7.jaxws.endpoint;
2+
3+
import java.util.ArrayList;
4+
import java.util.HashMap;
5+
import java.util.List;
6+
7+
import javax.jws.WebService;
8+
9+
/**
10+
*
11+
* @author Fermin Gallego
12+
*
13+
*/
14+
@WebService(endpointInterface = "org.javaee7.jaxws.endpoint.EBookStore",
15+
serviceName="EBookStoreImplService")
16+
public class EBookStoreImpl implements EBookStore{
17+
18+
private HashMap<String,EBook> eBookCollection=new HashMap<String,EBook>();
19+
20+
@Override
21+
public String welcomeMessage(String name) {
22+
return "Welcome to EBookStore WebService, Mr/Mrs "+name;
23+
}
24+
25+
@Override
26+
public List<String> findEBooks(String text) {
27+
List<String> foundTitles=new ArrayList<String>();
28+
for(String title:eBookCollection.keySet()){
29+
if(title.contains(text)){
30+
foundTitles.add(title);
31+
}
32+
}
33+
return foundTitles;
34+
}
35+
36+
@Override
37+
public EBook takeBook(String title) {
38+
return eBookCollection.get(title);
39+
}
40+
41+
@Override
42+
public void saveBook(EBook eBook) {
43+
eBookCollection.put(eBook.getTitle(), eBook);
44+
45+
}
46+
47+
@Override
48+
public EBook addAppendix(EBook eBook,int appendixPages) {
49+
eBook.setNumPages((eBook.getNumPages()+appendixPages));
50+
eBookCollection.put(eBook.getTitle(), eBook);
51+
return eBook;
52+
}
53+
54+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
2+
package org.javaee7.jaxws.endpoint.jaxws;
3+
4+
import javax.xml.bind.annotation.XmlAccessType;
5+
import javax.xml.bind.annotation.XmlAccessorType;
6+
import javax.xml.bind.annotation.XmlElement;
7+
import javax.xml.bind.annotation.XmlRootElement;
8+
import javax.xml.bind.annotation.XmlType;
9+
import org.javaee7.jaxws.endpoint.EBook;
10+
11+
@XmlRootElement(name = "addAppendix", namespace = "http://endpoint.jaxws.javaee7.org/")
12+
@XmlAccessorType(XmlAccessType.FIELD)
13+
@XmlType(name = "addAppendix", namespace = "http://endpoint.jaxws.javaee7.org/", propOrder = {
14+
"arg0",
15+
"arg1"
16+
})
17+
public class AddAppendix {
18+
19+
@XmlElement(name = "arg0", namespace = "")
20+
private EBook arg0;
21+
@XmlElement(name = "arg1", namespace = "")
22+
private int arg1;
23+
24+
/**
25+
*
26+
* @return
27+
* returns EBook
28+
*/
29+
public EBook getArg0() {
30+
return this.arg0;
31+
}
32+
33+
/**
34+
*
35+
* @param arg0
36+
* the value for the arg0 property
37+
*/
38+
public void setArg0(EBook arg0) {
39+
this.arg0 = arg0;
40+
}
41+
42+
/**
43+
*
44+
* @return
45+
* returns int
46+
*/
47+
public int getArg1() {
48+
return this.arg1;
49+
}
50+
51+
/**
52+
*
53+
* @param arg1
54+
* the value for the arg1 property
55+
*/
56+
public void setArg1(int arg1) {
57+
this.arg1 = arg1;
58+
}
59+
60+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
2+
package org.javaee7.jaxws.endpoint.jaxws;
3+
4+
import javax.xml.bind.annotation.XmlAccessType;
5+
import javax.xml.bind.annotation.XmlAccessorType;
6+
import javax.xml.bind.annotation.XmlElement;
7+
import javax.xml.bind.annotation.XmlRootElement;
8+
import javax.xml.bind.annotation.XmlType;
9+
import org.javaee7.jaxws.endpoint.EBook;
10+
11+
@XmlRootElement(name = "addAppendixResponse", namespace = "http://endpoint.jaxws.javaee7.org/")
12+
@XmlAccessorType(XmlAccessType.FIELD)
13+
@XmlType(name = "addAppendixResponse", namespace = "http://endpoint.jaxws.javaee7.org/")
14+
public class AddAppendixResponse {
15+
16+
@XmlElement(name = "return", namespace = "")
17+
private EBook _return;
18+
19+
/**
20+
*
21+
* @return
22+
* returns EBook
23+
*/
24+
public EBook getReturn() {
25+
return this._return;
26+
}
27+
28+
/**
29+
*
30+
* @param _return
31+
* the value for the _return property
32+
*/
33+
public void setReturn(EBook _return) {
34+
this._return = _return;
35+
}
36+
37+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
2+
package org.javaee7.jaxws.endpoint.jaxws;
3+
4+
import javax.xml.bind.annotation.XmlAccessType;
5+
import javax.xml.bind.annotation.XmlAccessorType;
6+
import javax.xml.bind.annotation.XmlElement;
7+
import javax.xml.bind.annotation.XmlRootElement;
8+
import javax.xml.bind.annotation.XmlType;
9+
10+
@XmlRootElement(name = "findEBooks", namespace = "http://endpoint.jaxws.javaee7.org/")
11+
@XmlAccessorType(XmlAccessType.FIELD)
12+
@XmlType(name = "findEBooks", namespace = "http://endpoint.jaxws.javaee7.org/")
13+
public class FindEBooks {
14+
15+
@XmlElement(name = "arg0", namespace = "")
16+
private String arg0;
17+
18+
/**
19+
*
20+
* @return
21+
* returns String
22+
*/
23+
public String getArg0() {
24+
return this.arg0;
25+
}
26+
27+
/**
28+
*
29+
* @param arg0
30+
* the value for the arg0 property
31+
*/
32+
public void setArg0(String arg0) {
33+
this.arg0 = arg0;
34+
}
35+
36+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
2+
package org.javaee7.jaxws.endpoint.jaxws;
3+
4+
import java.util.List;
5+
import javax.xml.bind.annotation.XmlAccessType;
6+
import javax.xml.bind.annotation.XmlAccessorType;
7+
import javax.xml.bind.annotation.XmlElement;
8+
import javax.xml.bind.annotation.XmlRootElement;
9+
import javax.xml.bind.annotation.XmlType;
10+
11+
@XmlRootElement(name = "findEBooksResponse", namespace = "http://endpoint.jaxws.javaee7.org/")
12+
@XmlAccessorType(XmlAccessType.FIELD)
13+
@XmlType(name = "findEBooksResponse", namespace = "http://endpoint.jaxws.javaee7.org/")
14+
public class FindEBooksResponse {
15+
16+
@XmlElement(name = "return", namespace = "")
17+
private List<String> _return;
18+
19+
/**
20+
*
21+
* @return
22+
* returns List<String>
23+
*/
24+
public List<String> getReturn() {
25+
return this._return;
26+
}
27+
28+
/**
29+
*
30+
* @param _return
31+
* the value for the _return property
32+
*/
33+
public void setReturn(List<String> _return) {
34+
this._return = _return;
35+
}
36+
37+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
2+
package org.javaee7.jaxws.endpoint.jaxws;
3+
4+
import javax.xml.bind.annotation.XmlAccessType;
5+
import javax.xml.bind.annotation.XmlAccessorType;
6+
import javax.xml.bind.annotation.XmlElement;
7+
import javax.xml.bind.annotation.XmlRootElement;
8+
import javax.xml.bind.annotation.XmlType;
9+
import org.javaee7.jaxws.endpoint.EBook;
10+
11+
@XmlRootElement(name = "saveBook", namespace = "http://endpoint.jaxws.javaee7.org/")
12+
@XmlAccessorType(XmlAccessType.FIELD)
13+
@XmlType(name = "saveBook", namespace = "http://endpoint.jaxws.javaee7.org/")
14+
public class SaveBook {
15+
16+
@XmlElement(name = "arg0", namespace = "")
17+
private EBook arg0;
18+
19+
/**
20+
*
21+
* @return
22+
* returns EBook
23+
*/
24+
public EBook getArg0() {
25+
return this.arg0;
26+
}
27+
28+
/**
29+
*
30+
* @param arg0
31+
* the value for the arg0 property
32+
*/
33+
public void setArg0(EBook arg0) {
34+
this.arg0 = arg0;
35+
}
36+
37+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
package org.javaee7.jaxws.endpoint.jaxws;
3+
4+
import javax.xml.bind.annotation.XmlAccessType;
5+
import javax.xml.bind.annotation.XmlAccessorType;
6+
import javax.xml.bind.annotation.XmlRootElement;
7+
import javax.xml.bind.annotation.XmlType;
8+
9+
@XmlRootElement(name = "saveBookResponse", namespace = "http://endpoint.jaxws.javaee7.org/")
10+
@XmlAccessorType(XmlAccessType.FIELD)
11+
@XmlType(name = "saveBookResponse", namespace = "http://endpoint.jaxws.javaee7.org/")
12+
public class SaveBookResponse {
13+
14+
15+
}

0 commit comments

Comments
 (0)