Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf298e23

Browse files
committed
add * [基于JAX-WS实现Web服务](samples/java-ws)
1 parent5d31429 commitf298e23

File tree

7 files changed

+141
-0
lines changed

7 files changed

+141
-0
lines changed

‎README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Distributed Java.Let's [READ](SUMMARY.md)!
2323
*[在Java中实现常用网络I/O模型](samples/java-io-mode)
2424
*[并发带来的风险——死锁](samples/java-concurrency)
2525
*[基于Java RMI实现分布式对象通信](samples/java-rmi)
26+
*[基于JAX-WS实现Web服务](samples/java-ws)
2627
*[基于JMS的消息发送和接收](samples/jms-msg)
2728
*[基于Jersey来构建REST服务](samples/jersey-rest)
2829
*[基于Apache CXF来构建REST服务](samples/cxf-rest)

‎samples/java-ws/.gitignore‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/target/
2+
/.idea/
3+
/.settings/
4+
.classpath
5+
.project

‎samples/java-ws/pom.xml‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<projectxmlns="http://maven.apache.org/POM/4.0.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<groupId>com.waylau</groupId>
7+
<artifactId>java-ws</artifactId>
8+
<version>1.0.0</version>
9+
<packaging>jar</packaging>
10+
11+
<name>java-ws</name>
12+
<url>https://waylau.com</url>
13+
14+
<properties>
15+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
16+
<maven.compiler.source>1.8</maven.compiler.source>
17+
<maven.compiler.target>${maven.compiler.source}</maven.compiler.target>
18+
<jaxws-api.version>2.3.1</jaxws-api.version>
19+
<junit.jupiter.version>5.5.2</junit.jupiter.version>
20+
</properties>
21+
<build>
22+
<plugins>
23+
<plugin>
24+
<artifactId>maven-compiler-plugin</artifactId>
25+
<version>3.8.1</version>
26+
</plugin>
27+
28+
</plugins>
29+
</build>
30+
<dependencies>
31+
<dependency>
32+
<groupId>javax.xml.ws</groupId>
33+
<artifactId>jaxws-api</artifactId>
34+
<version>${jaxws-api.version}</version>
35+
<scope>runtime</scope>
36+
</dependency>
37+
38+
<dependency>
39+
<groupId>org.junit.jupiter</groupId>
40+
<artifactId>junit-jupiter</artifactId>
41+
<version>${junit.jupiter.version}</version>
42+
<scope>test</scope>
43+
</dependency>
44+
45+
</dependencies>
46+
</project>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* Welcome to https://waylau.com
3+
*/
4+
packagecom.waylau.java.ws;
5+
6+
importjava.net.URL;
7+
importjavax.xml.namespace.QName;
8+
importjavax.xml.ws.Service;
9+
10+
/**
11+
* Hello Client.
12+
*
13+
* @since 1.0.0 2020年1月25日
14+
* @author <a href="https://waylau.com">Way Lau</a>
15+
*/
16+
publicclassHelloClient {
17+
18+
publicstaticvoidmain(String[]args)throwsException {
19+
URLurl =newURL("http://localhost:9999/ws/hello?wsdl");
20+
QNameqname =newQName("http://ws.java.waylau.com/",
21+
"HelloServiceImplService");
22+
23+
Serviceservice =Service.create(url,qname);
24+
25+
HelloServicehello =service.getPort(HelloService.class);
26+
System.out.println(hello.getHelloworld());
27+
28+
}
29+
30+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* Welcome to https://waylau.com
3+
*/
4+
packagecom.waylau.java.ws;
5+
6+
importjavax.xml.ws.Endpoint;
7+
8+
/**
9+
* Hello Publisher.
10+
*
11+
* @since 1.0.0 2020年1月25日
12+
* @author <a href="https://waylau.com">Way Lau</a>
13+
*/
14+
publicclassHelloPublisher {
15+
publicstaticvoidmain(String[]args) {
16+
17+
Endpoint.publish("http://localhost:9999/ws/hello",
18+
newHelloServiceImpl());
19+
20+
}
21+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* Welcome to https://waylau.com
3+
*/
4+
packagecom.waylau.java.ws;
5+
6+
importjavax.jws.WebService;
7+
8+
/**
9+
* Hello Service.
10+
*
11+
* @since 1.0.0 2020年1月25日
12+
* @author <a href="https://waylau.com">Way Lau</a>
13+
*/
14+
@WebService
15+
publicinterfaceHelloService {
16+
StringgetHelloworld();
17+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* Welcome to https://waylau.com
3+
*/
4+
packagecom.waylau.java.ws;
5+
6+
importjavax.jws.WebMethod;
7+
importjavax.jws.WebService;
8+
/**
9+
*
10+
* @since 1.0.0 2020年1月25日
11+
* @author <a href="https://waylau.com">Way Lau</a>
12+
*/
13+
@WebService(endpointInterface ="com.waylau.java.ws.HelloService")
14+
publicclassHelloServiceImplimplementsHelloService {
15+
16+
@WebMethod
17+
publicStringgetHelloworld() {
18+
return"Hello world!";
19+
}
20+
21+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp