forked from yudaocode/SpringBoot-Labs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
YunaiV
committed
Jun 15, 2020
1 parent
c269671
commit 1315127
Showing
5 changed files
with
122 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...ervice/src/main/java/cn/iocoder/springboot/lab65/userservice/config/WebServiceConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package cn.iocoder.springboot.lab65.userservice.config; | ||
|
||
import org.springframework.boot.autoconfigure.webservices.WebServicesProperties; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.core.io.ClassPathResource; | ||
import org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition; | ||
import org.springframework.xml.xsd.SimpleXsdSchema; | ||
import org.springframework.xml.xsd.XsdSchema; | ||
|
||
@Configuration | ||
public class WebServiceConfig { | ||
|
||
public static final String NAMESPACE_URI = "https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-65/lab-65-spring-ws-demo"; | ||
|
||
@Bean | ||
public XsdSchema usersSchema() { | ||
return new SimpleXsdSchema(new ClassPathResource("users.xsd")); | ||
} | ||
|
||
@Bean(name = "users") | ||
public DefaultWsdl11Definition defaultWsdl11Definition(XsdSchema usersSchema, WebServicesProperties properties) { | ||
DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition(); | ||
wsdl11Definition.setLocationUri(properties.getPath()); | ||
wsdl11Definition.setTargetNamespace(NAMESPACE_URI); | ||
wsdl11Definition.setSchema(usersSchema); | ||
wsdl11Definition.setPortTypeName("UsersPort"); | ||
return wsdl11Definition; | ||
} | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
...-service/src/main/java/cn/iocoder/springboot/lab65/userservice/endpoint/UserEndpoint.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package cn.iocoder.springboot.lab65.userservice.endpoint; | ||
|
||
import cn.iocoder.springboot.lab65.userservice.config.WebServiceConfig; | ||
import cn.iocoder.springboot.lab65.userservice.model.UserGetRequest; | ||
import cn.iocoder.springboot.lab65.userservice.model.UserGetResponse; | ||
import org.springframework.ws.server.endpoint.annotation.Endpoint; | ||
import org.springframework.ws.server.endpoint.annotation.PayloadRoot; | ||
import org.springframework.ws.server.endpoint.annotation.RequestPayload; | ||
import org.springframework.ws.server.endpoint.annotation.ResponsePayload; | ||
|
||
@Endpoint | ||
public class UserEndpoint { | ||
|
||
@PayloadRoot(namespace = WebServiceConfig.NAMESPACE_URI, localPart = "UserGetRequest") | ||
@ResponsePayload | ||
public UserGetResponse get(@RequestPayload UserGetRequest request) { | ||
UserGetResponse response = new UserGetResponse(); | ||
response.setId(request.getId()); | ||
response.setName("没有昵称:" + request.getId()); | ||
response.setGender(request.getId() % 2 + 1); | ||
return response; | ||
} | ||
|
||
} |
3 changes: 3 additions & 0 deletions
3
...b-65-spring-ws-demo/lab-65-spring-ws-demo-user-service/src/main/resources/application.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
spring: | ||
webservices: | ||
path: /ws |
44 changes: 24 additions & 20 deletions
44
lab-65/lab-65-spring-ws-demo/lab-65-spring-ws-demo-user-service/src/main/resources/users.xsd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,40 @@ | ||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://spring.io/guides/gs-producing-web-service" | ||
targetNamespace="http://spring.io/guides/gs-producing-web-service" elementFormDefault="qualified"> | ||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" | ||
targetNamespace="https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-65/lab-65-spring-ws-demo" | ||
elementFormDefault="qualified"> | ||
|
||
<xs:element name="getCountryRequest"> | ||
<xs:element name="UserGetRequest"> | ||
<xs:complexType> | ||
<xs:sequence> | ||
<xs:element name="id" type="xs:int"/> | ||
</xs:sequence> | ||
</xs:complexType> | ||
</xs:element> | ||
|
||
<xs:element name="UserGetResponse"> | ||
<xs:complexType> | ||
<xs:sequence> | ||
<xs:element name="id" type="xs:int" /> | ||
<xs:element name="name" type="xs:string"/> | ||
<xs:element name="gender" type="xs:int"/> | ||
</xs:sequence> | ||
</xs:complexType> | ||
</xs:element> | ||
|
||
<xs:element name="getCountryResponse"> | ||
<xs:element name="UserCreateRequest"> | ||
<xs:complexType> | ||
<xs:sequence> | ||
<xs:element name="country" type="tns:country"/> | ||
<xs:element name="name" type="xs:string"/> | ||
<xs:element name="gender" type="xs:int"/> | ||
</xs:sequence> | ||
</xs:complexType> | ||
</xs:element> | ||
|
||
<xs:complexType name="country"> | ||
<xs:sequence> | ||
<xs:element name="name" type="xs:string"/> | ||
<xs:element name="population" type="xs:int"/> | ||
<xs:element name="capital" type="xs:string"/> | ||
<xs:element name="currency" type="tns:currency"/> | ||
</xs:sequence> | ||
</xs:complexType> | ||
<xs:element name="UserCreateResponse"> | ||
<xs:complexType> | ||
<xs:sequence> | ||
<xs:element name="id" type="xs:int"/> | ||
</xs:sequence> | ||
</xs:complexType> | ||
</xs:element> | ||
|
||
<xs:simpleType name="currency"> | ||
<xs:restriction base="xs:string"> | ||
<xs:enumeration value="GBP"/> | ||
<xs:enumeration value="EUR"/> | ||
<xs:enumeration value="PLN"/> | ||
</xs:restriction> | ||
</xs:simpleType> | ||
</xs:schema> |