@@ -0,0 +1,144 @@
//
// Este archivo ha sido generado por la arquitectura JavaTM para la implantación de la referencia de enlace (JAXB) XML v2.2.7
// Visite <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Todas las modificaciones realizadas en este archivo se perderán si se vuelve a compilar el esquema de origen.
// Generado el: 2018.04.14 a las 03:47:37 PM CEST
//


package io.spring.guides.gs_producing_web_service;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;


/**
* <p>Clase Java para country complex type.
*
* <p>El siguiente fragmento de esquema especifica el contenido que se espera que haya en esta clase.
*
* <pre>
* &lt;complexType name="country">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="name" type="{http://www.w3.org/2001/XMLSchema}string"/>
* &lt;element name="population" type="{http://www.w3.org/2001/XMLSchema}int"/>
* &lt;element name="capital" type="{http://www.w3.org/2001/XMLSchema}string"/>
* &lt;element name="currency" type="{http://spring.io/guides/gs-producing-web-service}currency"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "country", propOrder = {
"name",
"population",
"capital",
"currency"
})
public class Country {

@XmlElement(required = true)
protected String name;
protected int population;
@XmlElement(required = true)
protected String capital;
@XmlElement(required = true)
protected Currency currency;

/**
* 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 population.
*
*/
public int getPopulation() {
return population;
}

/**
* Define el valor de la propiedad population.
*
*/
public void setPopulation(int value) {
this.population = value;
}

/**
* Obtiene el valor de la propiedad capital.
*
* @return
* possible object is
* {@link String }
*
*/
public String getCapital() {
return capital;
}

/**
* Define el valor de la propiedad capital.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setCapital(String value) {
this.capital = value;
}

/**
* Obtiene el valor de la propiedad currency.
*
* @return
* possible object is
* {@link Currency }
*
*/
public Currency getCurrency() {
return currency;
}

/**
* Define el valor de la propiedad currency.
*
* @param value
* allowed object is
* {@link Currency }
*
*/
public void setCurrency(Currency value) {
this.currency = value;
}

}
@@ -0,0 +1,47 @@
//
// Este archivo ha sido generado por la arquitectura JavaTM para la implantación de la referencia de enlace (JAXB) XML v2.2.7
// Visite <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Todas las modificaciones realizadas en este archivo se perderán si se vuelve a compilar el esquema de origen.
// Generado el: 2018.04.14 a las 03:47:37 PM CEST
//


package io.spring.guides.gs_producing_web_service;

import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlType;


/**
* <p>Clase Java para currency.
*
* <p>El siguiente fragmento de esquema especifica el contenido que se espera que haya en esta clase.
* <p>
* <pre>
* &lt;simpleType name="currency">
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}string">
* &lt;enumeration value="GBP"/>
* &lt;enumeration value="EUR"/>
* &lt;enumeration value="PLN"/>
* &lt;/restriction>
* &lt;/simpleType>
* </pre>
*
*/
@XmlType(name = "currency")
@XmlEnum
public enum Currency {

GBP,
EUR,
PLN;

public String value() {
return name();
}

public static Currency fromValue(String v) {
return valueOf(v);
}

}
@@ -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.2.7
// Visite <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Todas las modificaciones realizadas en este archivo se perderán si se vuelve a compilar el esquema de origen.
// Generado el: 2018.04.14 a las 03:47:37 PM CEST
//


package io.spring.guides.gs_producing_web_service;

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>
* &lt;complexType>
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="name" type="{http://www.w3.org/2001/XMLSchema}string"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"name"
})
@XmlRootElement(name = "getCountryRequest")
public class GetCountryRequest {

@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;
}

}
@@ -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.2.7
// Visite <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Todas las modificaciones realizadas en este archivo se perderán si se vuelve a compilar el esquema de origen.
// Generado el: 2018.04.14 a las 03:47:37 PM CEST
//


package io.spring.guides.gs_producing_web_service;

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>
* &lt;complexType>
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="country" type="{http://spring.io/guides/gs-producing-web-service}country"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"country"
})
@XmlRootElement(name = "getCountryResponse")
public class GetCountryResponse {

@XmlElement(required = true)
protected Country country;

/**
* Obtiene el valor de la propiedad country.
*
* @return
* possible object is
* {@link Country }
*
*/
public Country getCountry() {
return country;
}

/**
* Define el valor de la propiedad country.
*
* @param value
* allowed object is
* {@link Country }
*
*/
public void setCountry(Country value) {
this.country = value;
}

}
@@ -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.2.7
// Visite <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Todas las modificaciones realizadas en este archivo se perderán si se vuelve a compilar el esquema de origen.
// Generado el: 2018.04.14 a las 03:47:37 PM CEST
//


package io.spring.guides.gs_producing_web_service;

import javax.xml.bind.annotation.XmlRegistry;


/**
* This object contains factory methods for each
* Java content interface and Java element interface
* generated in the io.spring.guides.gs_producing_web_service 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: io.spring.guides.gs_producing_web_service
*
*/
public ObjectFactory() {
}

/**
* Create an instance of {@link GetCountryRequest }
*
*/
public GetCountryRequest createGetCountryRequest() {
return new GetCountryRequest();
}

/**
* Create an instance of {@link GetCountryResponse }
*
*/
public GetCountryResponse createGetCountryResponse() {
return new GetCountryResponse();
}

/**
* Create an instance of {@link Country }
*
*/
public Country createCountry() {
return new Country();
}

}
@@ -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.2.7
// Visite <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Todas las modificaciones realizadas en este archivo se perderán si se vuelve a compilar el esquema de origen.
// Generado el: 2018.04.14 a las 03:47:37 PM CEST
//

@javax.xml.bind.annotation.XmlSchema(namespace = "http://spring.io/guides/gs-producing-web-service", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
package io.spring.guides.gs_producing_web_service;
@@ -0,0 +1,8 @@
# ===================================================================
# COMMON SPRING BOOT PROPERTIES
#
# This sample file is provided as a guideline. Do NOT copy it in its
# entirety to your own application. ^^^
# ===================================================================

server.port=8081
@@ -0,0 +1,38 @@
<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:element name="getCountryRequest">
<xs:complexType>
<xs:sequence>
<xs:element name="name" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>

<xs:element name="getCountryResponse">
<xs:complexType>
<xs:sequence>
<xs:element name="country" type="tns:country"/>
</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: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>
@@ -0,0 +1,40 @@
package management;

import static org.assertj.core.api.Assertions.*;

import io.spring.guides.gs_producing_web_service.GetCountryRequest;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.oxm.jaxb.Jaxb2Marshaller;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.util.ClassUtils;
import org.springframework.ws.client.core.WebServiceTemplate;

@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
public class ApplicationIntegrationTests {

private Jaxb2Marshaller marshaller = new Jaxb2Marshaller();

@LocalServerPort
private int port = 0;

@Before
public void init() throws Exception {
marshaller.setPackagesToScan(ClassUtils.getPackageName(GetCountryRequest.class));
marshaller.afterPropertiesSet();
}

@Test
public void testSendAndReceive() {
WebServiceTemplate ws = new WebServiceTemplate(marshaller);
GetCountryRequest request = new GetCountryRequest();
request.setName("Spain");

assertThat(ws.marshalSendAndReceive("http://localhost:" + port + "/ws", request)).isNotNull();
}
}