initial commit
Este commit está contenido en:
13
src/main/java/com/manalejandro/ws/ServletInitializer.java
Archivo normal
13
src/main/java/com/manalejandro/ws/ServletInitializer.java
Archivo normal
@@ -0,0 +1,13 @@
|
||||
package com.manalejandro.ws;
|
||||
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
||||
|
||||
public class ServletInitializer extends SpringBootServletInitializer {
|
||||
|
||||
@Override
|
||||
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
|
||||
return application.sources(WsApplication.class);
|
||||
}
|
||||
|
||||
}
|
||||
43
src/main/java/com/manalejandro/ws/WebServiceConfig.java
Archivo normal
43
src/main/java/com/manalejandro/ws/WebServiceConfig.java
Archivo normal
@@ -0,0 +1,43 @@
|
||||
package com.manalejandro.ws;
|
||||
|
||||
import org.springframework.boot.web.servlet.ServletRegistrationBean;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.ws.config.annotation.EnableWs;
|
||||
import org.springframework.ws.config.annotation.WsConfigurerAdapter;
|
||||
import org.springframework.ws.transport.http.MessageDispatcherServlet;
|
||||
import org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition;
|
||||
import org.springframework.xml.xsd.SimpleXsdSchema;
|
||||
import org.springframework.xml.xsd.XsdSchema;
|
||||
|
||||
@EnableWs
|
||||
@Configuration
|
||||
public class WebServiceConfig extends WsConfigurerAdapter {
|
||||
|
||||
@Bean
|
||||
public ServletRegistrationBean<MessageDispatcherServlet> messageDispatcherServlet(
|
||||
ApplicationContext applicationContext) {
|
||||
MessageDispatcherServlet servlet = new MessageDispatcherServlet();
|
||||
servlet.setApplicationContext(applicationContext);
|
||||
servlet.setTransformWsdlLocations(true);
|
||||
return new ServletRegistrationBean<MessageDispatcherServlet>(servlet, "/ws/*");
|
||||
}
|
||||
|
||||
@Bean(name = "persons")
|
||||
public DefaultWsdl11Definition defaultWsdl11Definition(XsdSchema personsSchema) {
|
||||
DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition();
|
||||
wsdl11Definition.setPortTypeName("PersonsPort");
|
||||
wsdl11Definition.setLocationUri("/ws");
|
||||
wsdl11Definition.setTargetNamespace("http://www.manalejandro.com/person");
|
||||
wsdl11Definition.setSchema(personsSchema);
|
||||
return wsdl11Definition;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public XsdSchema personsSchema() {
|
||||
return new SimpleXsdSchema(new ClassPathResource("person.xsd"));
|
||||
}
|
||||
|
||||
}
|
||||
13
src/main/java/com/manalejandro/ws/WsApplication.java
Archivo normal
13
src/main/java/com/manalejandro/ws/WsApplication.java
Archivo normal
@@ -0,0 +1,13 @@
|
||||
package com.manalejandro.ws;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class WsApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(WsApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
71
src/main/java/com/manalejandro/ws/model/GetPersonRequest.java
Archivo normal
71
src/main/java/com/manalejandro/ws/model/GetPersonRequest.java
Archivo normal
@@ -0,0 +1,71 @@
|
||||
//
|
||||
// Este archivo ha sido generado por la arquitectura JavaTM para la implantación de la referencia de enlace (JAXB) XML v2.3.0
|
||||
// Visite <a href="https://javaee.github.io/jaxb-v2/">https://javaee.github.io/jaxb-v2/</a>
|
||||
// Todas las modificaciones realizadas en este archivo se perderán si se vuelve a compilar el esquema de origen.
|
||||
// Generado el: 2019.05.19 a las 04:09:02 PM CEST
|
||||
//
|
||||
|
||||
|
||||
package com.manalejandro.ws.model;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Clase Java para anonymous complex type.
|
||||
*
|
||||
* <p>El siguiente fragmento de esquema especifica el contenido que se espera que haya en esta clase.
|
||||
*
|
||||
* <pre>
|
||||
* <complexType>
|
||||
* <complexContent>
|
||||
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
|
||||
* <sequence>
|
||||
* <element name="name" type="{http://www.w3.org/2001/XMLSchema}string"/>
|
||||
* </sequence>
|
||||
* </restriction>
|
||||
* </complexContent>
|
||||
* </complexType>
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(name = "", propOrder = {
|
||||
"name"
|
||||
})
|
||||
@XmlRootElement(name = "getPersonRequest")
|
||||
public class GetPersonRequest {
|
||||
|
||||
@XmlElement(required = true)
|
||||
protected String name;
|
||||
|
||||
/**
|
||||
* Obtiene el valor de la propiedad name.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Define el valor de la propiedad name.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public void setName(String value) {
|
||||
this.name = value;
|
||||
}
|
||||
|
||||
}
|
||||
71
src/main/java/com/manalejandro/ws/model/GetPersonResponse.java
Archivo normal
71
src/main/java/com/manalejandro/ws/model/GetPersonResponse.java
Archivo normal
@@ -0,0 +1,71 @@
|
||||
//
|
||||
// Este archivo ha sido generado por la arquitectura JavaTM para la implantación de la referencia de enlace (JAXB) XML v2.3.0
|
||||
// Visite <a href="https://javaee.github.io/jaxb-v2/">https://javaee.github.io/jaxb-v2/</a>
|
||||
// Todas las modificaciones realizadas en este archivo se perderán si se vuelve a compilar el esquema de origen.
|
||||
// Generado el: 2019.05.19 a las 04:09:02 PM CEST
|
||||
//
|
||||
|
||||
|
||||
package com.manalejandro.ws.model;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Clase Java para anonymous complex type.
|
||||
*
|
||||
* <p>El siguiente fragmento de esquema especifica el contenido que se espera que haya en esta clase.
|
||||
*
|
||||
* <pre>
|
||||
* <complexType>
|
||||
* <complexContent>
|
||||
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
|
||||
* <sequence>
|
||||
* <element name="Person" type="{http://www.manalejandro.com/person}Person"/>
|
||||
* </sequence>
|
||||
* </restriction>
|
||||
* </complexContent>
|
||||
* </complexType>
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(name = "", propOrder = {
|
||||
"person"
|
||||
})
|
||||
@XmlRootElement(name = "getPersonResponse")
|
||||
public class GetPersonResponse {
|
||||
|
||||
@XmlElement(name = "Person", required = true)
|
||||
protected Person person;
|
||||
|
||||
/**
|
||||
* Obtiene el valor de la propiedad person.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link Person }
|
||||
*
|
||||
*/
|
||||
public Person getPerson() {
|
||||
return person;
|
||||
}
|
||||
|
||||
/**
|
||||
* Define el valor de la propiedad person.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link Person }
|
||||
*
|
||||
*/
|
||||
public void setPerson(Person value) {
|
||||
this.person = value;
|
||||
}
|
||||
|
||||
}
|
||||
63
src/main/java/com/manalejandro/ws/model/ObjectFactory.java
Archivo normal
63
src/main/java/com/manalejandro/ws/model/ObjectFactory.java
Archivo normal
@@ -0,0 +1,63 @@
|
||||
//
|
||||
// Este archivo ha sido generado por la arquitectura JavaTM para la implantación de la referencia de enlace (JAXB) XML v2.3.0
|
||||
// Visite <a href="https://javaee.github.io/jaxb-v2/">https://javaee.github.io/jaxb-v2/</a>
|
||||
// Todas las modificaciones realizadas en este archivo se perderán si se vuelve a compilar el esquema de origen.
|
||||
// Generado el: 2019.05.19 a las 04:09:02 PM CEST
|
||||
//
|
||||
|
||||
|
||||
package com.manalejandro.ws.model;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRegistry;
|
||||
|
||||
|
||||
/**
|
||||
* This object contains factory methods for each
|
||||
* Java content interface and Java element interface
|
||||
* generated in the com.manalejandro.ws.model package.
|
||||
* <p>An ObjectFactory allows you to programatically
|
||||
* construct new instances of the Java representation
|
||||
* for XML content. The Java representation of XML
|
||||
* content can consist of schema derived interfaces
|
||||
* and classes representing the binding of schema
|
||||
* type definitions, element declarations and model
|
||||
* groups. Factory methods for each of these are
|
||||
* provided in this class.
|
||||
*
|
||||
*/
|
||||
@XmlRegistry
|
||||
public class ObjectFactory {
|
||||
|
||||
|
||||
/**
|
||||
* Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.manalejandro.ws.model
|
||||
*
|
||||
*/
|
||||
public ObjectFactory() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link GetPersonRequest }
|
||||
*
|
||||
*/
|
||||
public GetPersonRequest createGetPersonRequest() {
|
||||
return new GetPersonRequest();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link GetPersonResponse }
|
||||
*
|
||||
*/
|
||||
public GetPersonResponse createGetPersonResponse() {
|
||||
return new GetPersonResponse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link Person }
|
||||
*
|
||||
*/
|
||||
public Person createPerson() {
|
||||
return new Person();
|
||||
}
|
||||
|
||||
}
|
||||
147
src/main/java/com/manalejandro/ws/model/Person.java
Archivo normal
147
src/main/java/com/manalejandro/ws/model/Person.java
Archivo normal
@@ -0,0 +1,147 @@
|
||||
//
|
||||
// Este archivo ha sido generado por la arquitectura JavaTM para la implantación de la referencia de enlace (JAXB) XML v2.3.0
|
||||
// Visite <a href="https://javaee.github.io/jaxb-v2/">https://javaee.github.io/jaxb-v2/</a>
|
||||
// Todas las modificaciones realizadas en este archivo se perderán si se vuelve a compilar el esquema de origen.
|
||||
// Generado el: 2019.05.19 a las 04:09:02 PM CEST
|
||||
//
|
||||
|
||||
|
||||
package com.manalejandro.ws.model;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlSchemaType;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
import javax.xml.datatype.XMLGregorianCalendar;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Clase Java para Person complex type.
|
||||
*
|
||||
* <p>El siguiente fragmento de esquema especifica el contenido que se espera que haya en esta clase.
|
||||
*
|
||||
* <pre>
|
||||
* <complexType name="Person">
|
||||
* <complexContent>
|
||||
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
|
||||
* <sequence>
|
||||
* <element name="name" type="{http://www.w3.org/2001/XMLSchema}string"/>
|
||||
* <element name="telephone" type="{http://www.w3.org/2001/XMLSchema}int"/>
|
||||
* <element name="address" type="{http://www.w3.org/2001/XMLSchema}string"/>
|
||||
* <element name="birthday" type="{http://www.w3.org/2001/XMLSchema}date"/>
|
||||
* </sequence>
|
||||
* </restriction>
|
||||
* </complexContent>
|
||||
* </complexType>
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(name = "Person", propOrder = {
|
||||
"name",
|
||||
"telephone",
|
||||
"address",
|
||||
"birthday"
|
||||
})
|
||||
public class Person {
|
||||
|
||||
@XmlElement(required = true)
|
||||
protected String name;
|
||||
protected int telephone;
|
||||
@XmlElement(required = true)
|
||||
protected String address;
|
||||
@XmlElement(required = true)
|
||||
@XmlSchemaType(name = "date")
|
||||
protected XMLGregorianCalendar birthday;
|
||||
|
||||
/**
|
||||
* Obtiene el valor de la propiedad name.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Define el valor de la propiedad name.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public void setName(String value) {
|
||||
this.name = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtiene el valor de la propiedad telephone.
|
||||
*
|
||||
*/
|
||||
public int getTelephone() {
|
||||
return telephone;
|
||||
}
|
||||
|
||||
/**
|
||||
* Define el valor de la propiedad telephone.
|
||||
*
|
||||
*/
|
||||
public void setTelephone(int value) {
|
||||
this.telephone = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtiene el valor de la propiedad address.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
/**
|
||||
* Define el valor de la propiedad address.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public void setAddress(String value) {
|
||||
this.address = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtiene el valor de la propiedad birthday.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link XMLGregorianCalendar }
|
||||
*
|
||||
*/
|
||||
public XMLGregorianCalendar getBirthday() {
|
||||
return birthday;
|
||||
}
|
||||
|
||||
/**
|
||||
* Define el valor de la propiedad birthday.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link XMLGregorianCalendar }
|
||||
*
|
||||
*/
|
||||
public void setBirthday(XMLGregorianCalendar value) {
|
||||
this.birthday = value;
|
||||
}
|
||||
|
||||
}
|
||||
9
src/main/java/com/manalejandro/ws/model/package-info.java
Archivo normal
9
src/main/java/com/manalejandro/ws/model/package-info.java
Archivo normal
@@ -0,0 +1,9 @@
|
||||
//
|
||||
// Este archivo ha sido generado por la arquitectura JavaTM para la implantación de la referencia de enlace (JAXB) XML v2.3.0
|
||||
// Visite <a href="https://javaee.github.io/jaxb-v2/">https://javaee.github.io/jaxb-v2/</a>
|
||||
// Todas las modificaciones realizadas en este archivo se perderán si se vuelve a compilar el esquema de origen.
|
||||
// Generado el: 2019.05.19 a las 04:09:02 PM CEST
|
||||
//
|
||||
|
||||
@javax.xml.bind.annotation.XmlSchema(namespace = "http://www.manalejandro.com/person", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
|
||||
package com.manalejandro.ws.model;
|
||||
42
src/main/java/com/manalejandro/ws/repository/PersonRepository.java
Archivo normal
42
src/main/java/com/manalejandro/ws/repository/PersonRepository.java
Archivo normal
@@ -0,0 +1,42 @@
|
||||
package com.manalejandro.ws.repository;
|
||||
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.xml.datatype.DatatypeConfigurationException;
|
||||
import javax.xml.datatype.DatatypeFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import com.manalejandro.ws.model.Person;
|
||||
|
||||
@Component
|
||||
public class PersonRepository {
|
||||
private static final Map<String, Person> persons = new HashMap<String, Person>();
|
||||
|
||||
@PostConstruct
|
||||
public void initData() throws DatatypeConfigurationException {
|
||||
Person person1 = new Person();
|
||||
person1.setName("name1");
|
||||
person1.setTelephone(600123123);
|
||||
person1.setAddress("City 1");
|
||||
person1.setBirthday(DatatypeFactory.newInstance().newXMLGregorianCalendar(new GregorianCalendar(1980,0,1)));
|
||||
|
||||
persons.put(person1.getName(), person1);
|
||||
|
||||
Person person2 = new Person();
|
||||
person2.setName("name2");
|
||||
person2.setTelephone(600123123);
|
||||
person2.setAddress("City 2");
|
||||
person2.setBirthday(DatatypeFactory.newInstance().newXMLGregorianCalendar(new GregorianCalendar(1980,0,1)));
|
||||
|
||||
persons.put(person2.getName(), person2);
|
||||
}
|
||||
|
||||
public Person findPerson(String name) {
|
||||
Assert.notNull(name, "The Person's name must not be null");
|
||||
return persons.get(name);
|
||||
}
|
||||
}
|
||||
32
src/main/java/com/manalejandro/ws/services/PersonEndpoint.java
Archivo normal
32
src/main/java/com/manalejandro/ws/services/PersonEndpoint.java
Archivo normal
@@ -0,0 +1,32 @@
|
||||
package com.manalejandro.ws.services;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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;
|
||||
|
||||
import com.manalejandro.ws.model.GetPersonRequest;
|
||||
import com.manalejandro.ws.model.GetPersonResponse;
|
||||
import com.manalejandro.ws.repository.PersonRepository;
|
||||
|
||||
@Endpoint
|
||||
public class PersonEndpoint {
|
||||
private static final String NAMESPACE_URI = "http://www.manalejandro.com/person";
|
||||
|
||||
private PersonRepository personRepository;
|
||||
|
||||
@Autowired
|
||||
public PersonEndpoint(PersonRepository personRepository) {
|
||||
this.personRepository = personRepository;
|
||||
}
|
||||
|
||||
@PayloadRoot(namespace = NAMESPACE_URI, localPart = "getPersonRequest")
|
||||
@ResponsePayload
|
||||
public GetPersonResponse getPerson(@RequestPayload GetPersonRequest request) {
|
||||
GetPersonResponse response = new GetPersonResponse();
|
||||
response.setPerson(personRepository.findPerson(request.getName()));
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
||||
1
src/main/resources/application.properties
Archivo normal
1
src/main/resources/application.properties
Archivo normal
@@ -0,0 +1 @@
|
||||
|
||||
29
src/main/resources/person.xsd
Archivo normal
29
src/main/resources/person.xsd
Archivo normal
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.manalejandro.com/person" xmlns:tns="http://www.manalejandro.com/person" elementFormDefault="qualified">
|
||||
|
||||
<xs:element name="getPersonRequest">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="name" type="xs:string"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
<xs:element name="getPersonResponse">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="Person" type="tns:Person"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
<xs:complexType name="Person">
|
||||
<xs:sequence>
|
||||
<xs:element name="name" type="xs:string"/>
|
||||
<xs:element name="telephone" type="xs:int"/>
|
||||
<xs:element name="address" type="xs:string"/>
|
||||
<xs:element name="birthday" type="xs:date"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
|
||||
</xs:schema>
|
||||
16
src/test/java/com/manalejandro/ws/WsApplicationTests.java
Archivo normal
16
src/test/java/com/manalejandro/ws/WsApplicationTests.java
Archivo normal
@@ -0,0 +1,16 @@
|
||||
package com.manalejandro.ws;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class WsApplicationTests {
|
||||
|
||||
@Test
|
||||
public void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
||||
Referencia en una nueva incidencia
Block a user