Skip to content

Commit 92aeb79

Browse files
author
YunaiV
committed
开始 WebService 入门示例
1 parent 0c95e44 commit 92aeb79

File tree

16 files changed

+284
-48
lines changed

16 files changed

+284
-48
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@
5858
* [《芋道 Spring Boot Dubbo 入门》](http://www.iocoder.cn/Spring-Boot/Dubbo/?github) 对应 [lab-30](https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-30)
5959
* [《芋道 Spring Boot 声明式调用 Feign 入门》](http://www.iocoder.cn/Spring-Boot/Feign/?github) 对应 [lab-58](https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-58)
6060
* [《芋道 Spring Boot gRPC 入门》](http://www.iocoder.cn/Spring-Boot/gRPC/?github) 对应 [lab-64](https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-64)
61+
* [《芋道 Spring Boot Web Services 入门》](http://www.iocoder.cn/Spring-Boot/Web-Services/?github) 对应 [lab-65](https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-65)
6162
* [《芋道 Spring Boot SOFARPC 入门》](http://www.iocoder.cn/Spring-Boot/SOFARPC/?github) 对应 [lab-62](https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-62)
6263
* [《芋道 Spring Boot Motan 入门》](http://www.iocoder.cn/Spring-Boot/Motan/?github) 对应 [lab-63](https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-63)
63-
* 《芋道 Spring Boot gRPC 入门》计划中...
6464
* 《芋道 Spring Boot RSocket 入门》计划中...
6565

6666
## 数据访问

lab-15/lab-15-spring-data-elasticsearch/pom.xml

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
<artifactId>spring-boot-starter-test</artifactId>
2626
<scope>test</scope>
2727
</dependency>
28-
2928
</dependencies>
3029

3130
</project>

lab-65/lab-65-cxf-ws-demo/lab-65-cxf-ws-demo-application/src/main/java/cn/iocoder/springboot/lab65/demo/config/CXFConfig.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package cn.iocoder.springboot.lab65.demo.config;
22

3-
import https.github_com.yunaiv.springboot_labs.tree.master.lab_65.lab_65_spring_ws_demo.UserService;
3+
import https.github_com.yunaiv.springboot_labs.tree.master.lab_65.lab_65_cxf_ws_demo.UserService;
44
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
55
import org.springframework.context.annotation.Bean;
66
import org.springframework.context.annotation.Configuration;

lab-65/lab-65-cxf-ws-demo/lab-65-cxf-ws-demo-application/src/main/java/cn/iocoder/springboot/lab65/demo/controller/DemoController.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package cn.iocoder.springboot.lab65.demo.controller;
22

3-
import https.github_com.yunaiv.springboot_labs.tree.master.lab_65.lab_65_spring_ws_demo.*;
3+
import https.github_com.yunaiv.springboot_labs.tree.master.lab_65.lab_65_cxf_ws_demo.*;
44
import org.springframework.beans.factory.annotation.Autowired;
55
import org.springframework.web.bind.annotation.GetMapping;
66
import org.springframework.web.bind.annotation.RequestMapping;
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,101 @@
1-
<wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-65/lab-65-spring-ws-demo" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http" name="userService" targetNamespace="https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-65/lab-65-spring-ws-demo">
1+
<wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-65/lab-65-cxf-ws-demo" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http" name="userService" targetNamespace="https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-65/lab-65-cxf-ws-demo">
22
<wsdl:types>
3-
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-65/lab-65-spring-ws-demo" elementFormDefault="unqualified" targetNamespace="https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-65/lab-65-spring-ws-demo" version="1.0">
3+
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-65/lab-65-cxf-ws-demo" elementFormDefault="unqualified" targetNamespace="https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-65/lab-65-cxf-ws-demo" version="1.0">
44
<xs:element name="create" type="tns:create"/>
55
<xs:element name="createResponse" type="tns:createResponse"/>
66
<xs:element name="get" type="tns:get"/>
77
<xs:element name="getResponse" type="tns:getResponse"/>
8-
<xs:complexType name="get">
8+
<xs:complexType name="create">
99
<xs:sequence>
10-
<xs:element minOccurs="0" name="arg0" type="tns:userGetRequest"/>
10+
<xs:element minOccurs="0" name="arg0" type="tns:userCreateRequest"/>
1111
</xs:sequence>
1212
</xs:complexType>
13-
<xs:complexType name="userGetRequest">
13+
<xs:complexType name="userCreateRequest">
1414
<xs:sequence>
15-
<xs:element minOccurs="0" name="id" type="xs:int"/>
15+
<xs:element minOccurs="0" name="gender" type="xs:int"/>
16+
<xs:element minOccurs="0" name="name" type="xs:string"/>
1617
</xs:sequence>
1718
</xs:complexType>
18-
<xs:complexType name="getResponse">
19+
<xs:complexType name="createResponse">
1920
<xs:sequence>
20-
<xs:element minOccurs="0" name="return" type="tns:userGetResponse"/>
21+
<xs:element minOccurs="0" name="return" type="tns:userCreateResponse"/>
2122
</xs:sequence>
2223
</xs:complexType>
23-
<xs:complexType name="userGetResponse">
24+
<xs:complexType name="userCreateResponse">
2425
<xs:sequence>
25-
<xs:element minOccurs="0" name="gender" type="xs:int"/>
2626
<xs:element minOccurs="0" name="id" type="xs:int"/>
27-
<xs:element minOccurs="0" name="name" type="xs:string"/>
2827
</xs:sequence>
2928
</xs:complexType>
30-
<xs:complexType name="create">
29+
<xs:complexType name="get">
3130
<xs:sequence>
32-
<xs:element minOccurs="0" name="arg0" type="tns:userCreateRequest"/>
31+
<xs:element minOccurs="0" name="arg0" type="tns:userGetRequest"/>
3332
</xs:sequence>
3433
</xs:complexType>
35-
<xs:complexType name="userCreateRequest">
34+
<xs:complexType name="userGetRequest">
3635
<xs:sequence>
37-
<xs:element minOccurs="0" name="gender" type="xs:int"/>
38-
<xs:element minOccurs="0" name="name" type="xs:string"/>
36+
<xs:element minOccurs="0" name="id" type="xs:int"/>
3937
</xs:sequence>
4038
</xs:complexType>
41-
<xs:complexType name="createResponse">
39+
<xs:complexType name="getResponse">
4240
<xs:sequence>
43-
<xs:element minOccurs="0" name="return" type="tns:userCreateResponse"/>
41+
<xs:element minOccurs="0" name="return" type="tns:userGetResponse"/>
4442
</xs:sequence>
4543
</xs:complexType>
46-
<xs:complexType name="userCreateResponse">
44+
<xs:complexType name="userGetResponse">
4745
<xs:sequence>
46+
<xs:element minOccurs="0" name="gender" type="xs:int"/>
4847
<xs:element minOccurs="0" name="id" type="xs:int"/>
48+
<xs:element minOccurs="0" name="name" type="xs:string"/>
4949
</xs:sequence>
5050
</xs:complexType>
5151
</xs:schema>
5252
</wsdl:types>
53-
<wsdl:message name="getResponse">
54-
<wsdl:part element="tns:getResponse" name="parameters"> </wsdl:part>
55-
</wsdl:message>
56-
<wsdl:message name="get">
57-
<wsdl:part element="tns:get" name="parameters"> </wsdl:part>
58-
</wsdl:message>
5953
<wsdl:message name="create">
6054
<wsdl:part element="tns:create" name="parameters"> </wsdl:part>
6155
</wsdl:message>
6256
<wsdl:message name="createResponse">
6357
<wsdl:part element="tns:createResponse" name="parameters"> </wsdl:part>
6458
</wsdl:message>
59+
<wsdl:message name="get">
60+
<wsdl:part element="tns:get" name="parameters"> </wsdl:part>
61+
</wsdl:message>
62+
<wsdl:message name="getResponse">
63+
<wsdl:part element="tns:getResponse" name="parameters"> </wsdl:part>
64+
</wsdl:message>
6565
<wsdl:portType name="UserService">
66-
<wsdl:operation name="get">
67-
<wsdl:input message="tns:get" name="get"> </wsdl:input>
68-
<wsdl:output message="tns:getResponse" name="getResponse"> </wsdl:output>
69-
</wsdl:operation>
7066
<wsdl:operation name="create">
7167
<wsdl:input message="tns:create" name="create"> </wsdl:input>
7268
<wsdl:output message="tns:createResponse" name="createResponse"> </wsdl:output>
7369
</wsdl:operation>
70+
<wsdl:operation name="get">
71+
<wsdl:input message="tns:get" name="get"> </wsdl:input>
72+
<wsdl:output message="tns:getResponse" name="getResponse"> </wsdl:output>
73+
</wsdl:operation>
7474
</wsdl:portType>
7575
<wsdl:binding name="userServiceSoapBinding" type="tns:UserService">
7676
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
77-
<wsdl:operation name="get">
77+
<wsdl:operation name="create">
7878
<soap:operation soapAction="" style="document"/>
79-
<wsdl:input name="get">
79+
<wsdl:input name="create">
8080
<soap:body use="literal"/>
8181
</wsdl:input>
82-
<wsdl:output name="getResponse">
82+
<wsdl:output name="createResponse">
8383
<soap:body use="literal"/>
8484
</wsdl:output>
8585
</wsdl:operation>
86-
<wsdl:operation name="create">
86+
<wsdl:operation name="get">
8787
<soap:operation soapAction="" style="document"/>
88-
<wsdl:input name="create">
88+
<wsdl:input name="get">
8989
<soap:body use="literal"/>
9090
</wsdl:input>
91-
<wsdl:output name="createResponse">
91+
<wsdl:output name="getResponse">
9292
<soap:body use="literal"/>
9393
</wsdl:output>
9494
</wsdl:operation>
9595
</wsdl:binding>
9696
<wsdl:service name="userService">
9797
<wsdl:port binding="tns:userServiceSoapBinding" name="UserServiceImplPort">
98-
<soap:address location="http://127.0.0.1:8080/ws/user"/>
98+
<soap:address location="http://127.0.0.1:9090/ws/user"/>
9999
</wsdl:port>
100100
</wsdl:service>
101101
</wsdl:definitions>

lab-65/lab-65-cxf-ws-demo/lab-65-cxf-ws-demo-user-service/src/main/java/cn/iocoder/springboot/lab65/userservice/config/CXFConfig.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
@Configuration
1212
public class CXFConfig {
1313

14-
public static final String NAMESPACE_URI = "https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-65/lab-65-spring-ws-demo";
14+
public static final String NAMESPACE_URI = "https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-65/lab-65-cxf-ws-demo";
1515

1616
@Bean(name = Bus.DEFAULT_BUS_ID)
1717
public SpringBus springBus() {

lab-65/lab-65-cxf-ws-demo/lab-65-cxf-ws-demo-user-service/src/main/java/cn/iocoder/springboot/lab65/userservice/service/UserServiceImpl.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
@Service
1313
@WebService(
1414
serviceName = "userService", // 服务名称
15-
targetNamespace = CXFConfig.NAMESPACE_URI // WSDL 命名空间
15+
targetNamespace = CXFConfig.NAMESPACE_URI // Namespace 命名空间
1616
)
1717
public class UserServiceImpl implements UserService {
1818

lab-65/lab-65-ws-feign-client/pom.xml

-6
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,6 @@
3939
<artifactId>spring-boot-starter-web</artifactId>
4040
</dependency>
4141

42-
<!-- 引入 Feign 相关依赖 -->
43-
<dependency>
44-
<groupId>io.github.openfeign</groupId>
45-
<artifactId>feign-core</artifactId>
46-
<version>11.0</version>
47-
</dependency>
4842
<!-- 引入 Feign SOAP 拓展的依赖 -->
4943
<dependency>
5044
<groupId>io.github.openfeign</groupId>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<http://www.iocoder.cn/Spring-Boot/Web-Services/?github>
+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<artifactId>lab-66</artifactId>
7+
<groupId>cn.iocoder.springboot.labs</groupId>
8+
<version>1.0-SNAPSHOT</version>
9+
</parent>
10+
<modelVersion>4.0.0</modelVersion>
11+
12+
<artifactId>lab-66-spring-data-solr</artifactId>
13+
14+
<properties>
15+
<!-- 依赖相关配置 -->
16+
<spring.boot.version>2.2.4.RELEASE</spring.boot.version>
17+
<!-- 插件相关配置 -->
18+
<maven.compiler.target>1.8</maven.compiler.target>
19+
<maven.compiler.source>1.8</maven.compiler.source>
20+
</properties>
21+
22+
<dependencyManagement>
23+
<dependencies>
24+
<dependency>
25+
<groupId>org.springframework.boot</groupId>
26+
<artifactId>spring-boot-starter-parent</artifactId>
27+
<version>${spring.boot.version}</version>
28+
<type>pom</type>
29+
<scope>import</scope>
30+
</dependency>
31+
</dependencies>
32+
</dependencyManagement>
33+
34+
<dependencies>
35+
<!-- 自动化配置 Spring Data Solr -->
36+
<dependency>
37+
<groupId>org.springframework.boot</groupId>
38+
<artifactId>spring-boot-starter-data-solr</artifactId>
39+
</dependency>
40+
41+
<!-- 方便等会写单元测试 -->
42+
<dependency>
43+
<groupId>org.springframework.boot</groupId>
44+
<artifactId>spring-boot-starter-test</artifactId>
45+
<scope>test</scope>
46+
</dependency>
47+
</dependencies>
48+
49+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package cn.iocoder.springboot.lab15.springdatasolr;
2+
3+
import org.springframework.boot.autoconfigure.SpringBootApplication;
4+
5+
@SpringBootApplication
6+
public class Application {
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
package cn.iocoder.springboot.lab15.springdatasolr.dataobject;
2+
3+
import org.springframework.data.annotation.Id;
4+
import org.springframework.data.solr.core.mapping.Indexed;
5+
import org.springframework.data.solr.core.mapping.SolrDocument;
6+
7+
@SolrDocument(collection = "new_core")
8+
public class SolrProductDO {
9+
10+
/**
11+
* ID 主键
12+
*/
13+
@Id
14+
private Integer id;
15+
16+
/**
17+
* SPU 名字
18+
*/
19+
@Indexed(value = "name")
20+
private String name;
21+
/**
22+
* 描述
23+
*/
24+
@Indexed(value = "description")
25+
private String description;
26+
/**
27+
* 分类编号
28+
*/
29+
@Indexed(value = "cid")
30+
private Integer cid;
31+
/**
32+
* 分类名
33+
*/
34+
@Indexed(value = "category_name")
35+
private String categoryName;
36+
37+
public Integer getId() {
38+
return id;
39+
}
40+
41+
public SolrProductDO setId(Integer id) {
42+
this.id = id;
43+
return this;
44+
}
45+
46+
public String getName() {
47+
return name;
48+
}
49+
50+
public SolrProductDO setName(String name) {
51+
this.name = name;
52+
return this;
53+
}
54+
55+
public String getDescription() {
56+
return description;
57+
}
58+
59+
public SolrProductDO setDescription(String description) {
60+
this.description = description;
61+
return this;
62+
}
63+
64+
public Integer getCid() {
65+
return cid;
66+
}
67+
68+
public SolrProductDO setCid(Integer cid) {
69+
this.cid = cid;
70+
return this;
71+
}
72+
73+
public String getCategoryName() {
74+
return categoryName;
75+
}
76+
77+
public SolrProductDO setCategoryName(String categoryName) {
78+
this.categoryName = categoryName;
79+
return this;
80+
}
81+
82+
@Override
83+
public String toString() {
84+
return "SolrProductDO{" +
85+
"id=" + id +
86+
", name='" + name + '\'' +
87+
", description='" + description + '\'' +
88+
", cid=" + cid +
89+
", categoryName='" + categoryName + '\'' +
90+
'}';
91+
}
92+
93+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package cn.iocoder.springboot.lab15.springdatasolr.repository;
2+
3+
import cn.iocoder.springboot.lab15.springdatasolr.dataobject.SolrProductDO;
4+
import org.springframework.data.solr.repository.SolrCrudRepository;
5+
6+
public interface ProductRepository extends SolrCrudRepository<SolrProductDO, Integer> {
7+
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
spring:
2+
data:
3+
solr:
4+
host: 'http://127.0.0.1:8983/solr'
5+
repositories:
6+
enabled: true

0 commit comments

Comments
 (0)