删除编译错误
This commit is contained in:
parent
a7b2f168b7
commit
e2820ab2e3
|
@ -1,135 +0,0 @@
|
||||||
|
|
||||||
package com.ossez.ws.client.generated;
|
|
||||||
|
|
||||||
import jakarta.xml.bind.annotation.XmlAccessType;
|
|
||||||
import jakarta.xml.bind.annotation.XmlAccessorType;
|
|
||||||
import jakarta.xml.bind.annotation.XmlSchemaType;
|
|
||||||
import jakarta.xml.bind.annotation.XmlType;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>Java class for country complex type.
|
|
||||||
*
|
|
||||||
* <p>The following schema fragment specifies the expected content contained within this class.
|
|
||||||
*
|
|
||||||
* <pre>
|
|
||||||
* <complexType name="country">
|
|
||||||
* <complexContent>
|
|
||||||
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
|
|
||||||
* <sequence>
|
|
||||||
* <element name="capital" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
|
|
||||||
* <element name="currency" type="{http://server.ws.soap.baeldung.com/}currency" minOccurs="0"/>
|
|
||||||
* <element name="name" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
|
|
||||||
* <element name="population" type="{http://www.w3.org/2001/XMLSchema}int"/>
|
|
||||||
* </sequence>
|
|
||||||
* </restriction>
|
|
||||||
* </complexContent>
|
|
||||||
* </complexType>
|
|
||||||
* </pre>
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
|
||||||
@XmlType(name = "country", propOrder = {
|
|
||||||
"capital",
|
|
||||||
"currency",
|
|
||||||
"name",
|
|
||||||
"population"
|
|
||||||
})
|
|
||||||
public class Country {
|
|
||||||
|
|
||||||
protected String capital;
|
|
||||||
@XmlSchemaType(name = "string")
|
|
||||||
protected Currency currency;
|
|
||||||
protected String name;
|
|
||||||
protected int population;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the value of the capital property.
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
* possible object is
|
|
||||||
* {@link String }
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public String getCapital() {
|
|
||||||
return capital;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the value of the capital property.
|
|
||||||
*
|
|
||||||
* @param value
|
|
||||||
* allowed object is
|
|
||||||
* {@link String }
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public void setCapital(String value) {
|
|
||||||
this.capital = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the value of the currency property.
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
* possible object is
|
|
||||||
* {@link Currency }
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public Currency getCurrency() {
|
|
||||||
return currency;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the value of the currency property.
|
|
||||||
*
|
|
||||||
* @param value
|
|
||||||
* allowed object is
|
|
||||||
* {@link Currency }
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public void setCurrency(Currency value) {
|
|
||||||
this.currency = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the value of the name property.
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
* possible object is
|
|
||||||
* {@link String }
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the value of the name property.
|
|
||||||
*
|
|
||||||
* @param value
|
|
||||||
* allowed object is
|
|
||||||
* {@link String }
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public void setName(String value) {
|
|
||||||
this.name = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the value of the population property.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public int getPopulation() {
|
|
||||||
return population;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the value of the population property.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public void setPopulation(int value) {
|
|
||||||
this.population = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,40 +0,0 @@
|
||||||
|
|
||||||
package com.ossez.ws.client.generated;
|
|
||||||
|
|
||||||
import jakarta.jws.WebMethod;
|
|
||||||
import jakarta.jws.WebParam;
|
|
||||||
import jakarta.jws.WebResult;
|
|
||||||
import jakarta.jws.WebService;
|
|
||||||
import jakarta.jws.soap.SOAPBinding;
|
|
||||||
import jakarta.xml.bind.annotation.XmlSeeAlso;
|
|
||||||
import jakarta.xml.ws.Action;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This class was generated by the JAX-WS RI.
|
|
||||||
* JAX-WS RI 3.0.2
|
|
||||||
* Generated source version: 3.0
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@WebService(name = "CountryService", targetNamespace = "http://server.ws.soap.baeldung.com/")
|
|
||||||
@SOAPBinding(style = SOAPBinding.Style.RPC)
|
|
||||||
@XmlSeeAlso({
|
|
||||||
ObjectFactory.class
|
|
||||||
})
|
|
||||||
public interface CountryService {
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param arg0
|
|
||||||
* @return
|
|
||||||
* returns Country
|
|
||||||
*/
|
|
||||||
@WebMethod
|
|
||||||
@WebResult(partName = "return")
|
|
||||||
@Action(input = "http://server.ws.soap.baeldung.com/CountryService/findByNameRequest", output = "http://server.ws.soap.baeldung.com/CountryService/findByNameResponse")
|
|
||||||
public Country findByName(
|
|
||||||
@WebParam(name = "arg0", partName = "arg0")
|
|
||||||
String arg0);
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,94 +0,0 @@
|
||||||
|
|
||||||
package com.ossez.ws.client.generated;
|
|
||||||
|
|
||||||
import java.net.MalformedURLException;
|
|
||||||
import java.net.URL;
|
|
||||||
import javax.xml.namespace.QName;
|
|
||||||
import jakarta.xml.ws.Service;
|
|
||||||
import jakarta.xml.ws.WebEndpoint;
|
|
||||||
import jakarta.xml.ws.WebServiceClient;
|
|
||||||
import jakarta.xml.ws.WebServiceException;
|
|
||||||
import jakarta.xml.ws.WebServiceFeature;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This class was generated by the JAX-WS RI.
|
|
||||||
* JAX-WS RI 3.0.2
|
|
||||||
* Generated source version: 3.0
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@WebServiceClient(name = "CountryServiceImplService", targetNamespace = "http://server.ws.soap.baeldung.com/", wsdlLocation = "http://localhost:8888/ws/country?wsdl")
|
|
||||||
public class CountryServiceImplService
|
|
||||||
extends Service
|
|
||||||
{
|
|
||||||
|
|
||||||
private final static URL COUNTRYSERVICEIMPLSERVICE_WSDL_LOCATION;
|
|
||||||
private final static WebServiceException COUNTRYSERVICEIMPLSERVICE_EXCEPTION;
|
|
||||||
private final static QName COUNTRYSERVICEIMPLSERVICE_QNAME = new QName("http://server.ws.soap.baeldung.com/", "CountryServiceImplService");
|
|
||||||
|
|
||||||
static {
|
|
||||||
URL url = null;
|
|
||||||
WebServiceException e = null;
|
|
||||||
try {
|
|
||||||
url = new URL("http://localhost:8888/ws/country?wsdl");
|
|
||||||
} catch (MalformedURLException ex) {
|
|
||||||
e = new WebServiceException(ex);
|
|
||||||
}
|
|
||||||
COUNTRYSERVICEIMPLSERVICE_WSDL_LOCATION = url;
|
|
||||||
COUNTRYSERVICEIMPLSERVICE_EXCEPTION = e;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CountryServiceImplService() {
|
|
||||||
super(__getWsdlLocation(), COUNTRYSERVICEIMPLSERVICE_QNAME);
|
|
||||||
}
|
|
||||||
|
|
||||||
public CountryServiceImplService(WebServiceFeature... features) {
|
|
||||||
super(__getWsdlLocation(), COUNTRYSERVICEIMPLSERVICE_QNAME, features);
|
|
||||||
}
|
|
||||||
|
|
||||||
public CountryServiceImplService(URL wsdlLocation) {
|
|
||||||
super(wsdlLocation, COUNTRYSERVICEIMPLSERVICE_QNAME);
|
|
||||||
}
|
|
||||||
|
|
||||||
public CountryServiceImplService(URL wsdlLocation, WebServiceFeature... features) {
|
|
||||||
super(wsdlLocation, COUNTRYSERVICEIMPLSERVICE_QNAME, features);
|
|
||||||
}
|
|
||||||
|
|
||||||
public CountryServiceImplService(URL wsdlLocation, QName serviceName) {
|
|
||||||
super(wsdlLocation, serviceName);
|
|
||||||
}
|
|
||||||
|
|
||||||
public CountryServiceImplService(URL wsdlLocation, QName serviceName, WebServiceFeature... features) {
|
|
||||||
super(wsdlLocation, serviceName, features);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
* returns CountryService
|
|
||||||
*/
|
|
||||||
@WebEndpoint(name = "CountryServiceImplPort")
|
|
||||||
public CountryService getCountryServiceImplPort() {
|
|
||||||
return super.getPort(new QName("http://server.ws.soap.baeldung.com/", "CountryServiceImplPort"), CountryService.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param features
|
|
||||||
* A list of {@link jakarta.xml.ws.WebServiceFeature} to configure on the proxy. Supported features not in the <code>features</code> parameter will have their default values.
|
|
||||||
* @return
|
|
||||||
* returns CountryService
|
|
||||||
*/
|
|
||||||
@WebEndpoint(name = "CountryServiceImplPort")
|
|
||||||
public CountryService getCountryServiceImplPort(WebServiceFeature... features) {
|
|
||||||
return super.getPort(new QName("http://server.ws.soap.baeldung.com/", "CountryServiceImplPort"), CountryService.class, features);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static URL __getWsdlLocation() {
|
|
||||||
if (COUNTRYSERVICEIMPLSERVICE_EXCEPTION!= null) {
|
|
||||||
throw COUNTRYSERVICEIMPLSERVICE_EXCEPTION;
|
|
||||||
}
|
|
||||||
return COUNTRYSERVICEIMPLSERVICE_WSDL_LOCATION;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,39 +0,0 @@
|
||||||
|
|
||||||
package com.ossez.ws.client.generated;
|
|
||||||
|
|
||||||
import jakarta.xml.bind.annotation.XmlEnum;
|
|
||||||
import jakarta.xml.bind.annotation.XmlType;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>Java class for currency.
|
|
||||||
*
|
|
||||||
* <p>The following schema fragment specifies the expected content contained within this class.
|
|
||||||
* <pre>
|
|
||||||
* <simpleType name="currency">
|
|
||||||
* <restriction base="{http://www.w3.org/2001/XMLSchema}string">
|
|
||||||
* <enumeration value="EUR"/>
|
|
||||||
* <enumeration value="INR"/>
|
|
||||||
* <enumeration value="USD"/>
|
|
||||||
* </restriction>
|
|
||||||
* </simpleType>
|
|
||||||
* </pre>
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@XmlType(name = "currency")
|
|
||||||
@XmlEnum
|
|
||||||
public enum Currency {
|
|
||||||
|
|
||||||
EUR,
|
|
||||||
INR,
|
|
||||||
USD;
|
|
||||||
|
|
||||||
public String value() {
|
|
||||||
return name();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Currency fromValue(String v) {
|
|
||||||
return valueOf(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,40 +0,0 @@
|
||||||
|
|
||||||
package com.ossez.ws.client.generated;
|
|
||||||
|
|
||||||
import jakarta.xml.bind.annotation.XmlRegistry;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This object contains factory methods for each
|
|
||||||
* Java content interface and Java element interface
|
|
||||||
* generated in the com.baeldung.soap.ws.client.generated 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.baeldung.soap.ws.client.generated
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public ObjectFactory() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create an instance of {@link Country }
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public Country createCountry() {
|
|
||||||
return new Country();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,2 +0,0 @@
|
||||||
@jakarta.xml.bind.annotation.XmlSchema(namespace = "http://server.ws.soap.baeldung.com/")
|
|
||||||
package com.ossez.ws.client.generated;
|
|
|
@ -1,41 +0,0 @@
|
||||||
package com.ossez.ws.server;
|
|
||||||
|
|
||||||
public class Country {
|
|
||||||
protected String name;
|
|
||||||
protected int population;
|
|
||||||
protected String capital;
|
|
||||||
protected Currency currency;
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPopulation() {
|
|
||||||
return population;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPopulation(int population) {
|
|
||||||
this.population = population;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getCapital() {
|
|
||||||
return capital;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCapital(String capital) {
|
|
||||||
this.capital = capital;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Currency getCurrency() {
|
|
||||||
return currency;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCurrency(Currency currency) {
|
|
||||||
this.currency = currency;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,43 +0,0 @@
|
||||||
package com.ossez.ws.server;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class CountryRepository {
|
|
||||||
|
|
||||||
private static final Map<String, Country> countries = new HashMap<>();
|
|
||||||
|
|
||||||
{
|
|
||||||
initData();
|
|
||||||
}
|
|
||||||
|
|
||||||
private final static void initData() {
|
|
||||||
Country usa = new Country();
|
|
||||||
usa.setName("USA");
|
|
||||||
usa.setCapital("Washington D.C.");
|
|
||||||
usa.setCurrency(Currency.USD);
|
|
||||||
usa.setPopulation(323947000);
|
|
||||||
|
|
||||||
countries.put(usa.getName(), usa);
|
|
||||||
|
|
||||||
Country india = new Country();
|
|
||||||
india.setName("India");
|
|
||||||
india.setCapital("New Delhi");
|
|
||||||
india.setCurrency(Currency.INR);
|
|
||||||
india.setPopulation(1295210000);
|
|
||||||
|
|
||||||
countries.put(india.getName(), india);
|
|
||||||
|
|
||||||
Country france = new Country();
|
|
||||||
france.setName("France");
|
|
||||||
france.setCapital("Paris");
|
|
||||||
france.setCurrency(Currency.EUR);
|
|
||||||
france.setPopulation(66710000);
|
|
||||||
|
|
||||||
countries.put(france.getName(), france);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Country findCountry(String name) {
|
|
||||||
return countries.get(name);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,15 +0,0 @@
|
||||||
package com.ossez.ws.server;
|
|
||||||
|
|
||||||
import jakarta.jws.WebMethod;
|
|
||||||
import jakarta.jws.WebService;
|
|
||||||
import jakarta.jws.soap.SOAPBinding;
|
|
||||||
import jakarta.jws.soap.SOAPBinding.Style;
|
|
||||||
|
|
||||||
@WebService
|
|
||||||
@SOAPBinding(style=Style.RPC)
|
|
||||||
public interface CountryService {
|
|
||||||
|
|
||||||
@WebMethod
|
|
||||||
Country findByName(String name);
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,15 +0,0 @@
|
||||||
package com.ossez.ws.server;
|
|
||||||
|
|
||||||
import jakarta.jws.WebService;
|
|
||||||
|
|
||||||
@WebService(endpointInterface = "com.ossez.ws.server.CountryService")
|
|
||||||
public class CountryServiceImpl implements CountryService {
|
|
||||||
|
|
||||||
private CountryRepository countryRepository = new CountryRepository();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Country findByName(String name) {
|
|
||||||
return countryRepository.findCountry(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,19 +0,0 @@
|
||||||
package com.ossez.ws.server;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import jakarta.xml.ws.Endpoint;
|
|
||||||
|
|
||||||
|
|
||||||
public class CountryServicePublisher {
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(CountryServicePublisher.class);
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
Endpoint endpoint = Endpoint.create(new CountryServiceImpl());
|
|
||||||
endpoint.publish("http://localhost:8888/ws/country");
|
|
||||||
|
|
||||||
logger.info("Country web service ready to consume requests!");
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,15 +0,0 @@
|
||||||
package com.ossez.ws.server;
|
|
||||||
|
|
||||||
public enum Currency {
|
|
||||||
|
|
||||||
EUR, INR, USD;
|
|
||||||
|
|
||||||
public String value() {
|
|
||||||
return name();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Currency fromValue(String v) {
|
|
||||||
return valueOf(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,54 +0,0 @@
|
||||||
package com.ossez.features;
|
|
||||||
|
|
||||||
import org.junit.jupiter.api.AfterAll;
|
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
import org.mockserver.integration.ClientAndServer;
|
|
||||||
import org.mockserver.model.HttpStatusCode;
|
|
||||||
import org.mockserver.socket.PortFactory;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URI;
|
|
||||||
import java.net.http.HttpClient;
|
|
||||||
import java.net.http.HttpRequest;
|
|
||||||
import java.net.http.HttpResponse;
|
|
||||||
import java.time.Duration;
|
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
|
||||||
import static org.mockserver.integration.ClientAndServer.startClientAndServer;
|
|
||||||
|
|
||||||
class HttpClientIntegrationTest {
|
|
||||||
|
|
||||||
private static ClientAndServer mockServer;
|
|
||||||
private static int port;
|
|
||||||
|
|
||||||
@BeforeAll
|
|
||||||
static void startServer() {
|
|
||||||
port = PortFactory.findFreePort();
|
|
||||||
mockServer = ClientAndServer.startClientAndServer(port);
|
|
||||||
mockServer.when(new org.mockserver.model.HttpRequest().withMethod("GET"))
|
|
||||||
.respond(new org.mockserver.model.HttpResponse()
|
|
||||||
.withStatusCode(HttpStatusCode.OK_200.code())
|
|
||||||
.withBody("Hello from the server!"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterAll
|
|
||||||
static void stopServer() {
|
|
||||||
mockServer.stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void givenSampleHttpRequest_whenRequestIsSent_thenServerResponseIsReceived() throws IOException, InterruptedException {
|
|
||||||
HttpClient httpClient = HttpClient.newBuilder()
|
|
||||||
.version(HttpClient.Version.HTTP_2)
|
|
||||||
.connectTimeout(Duration.ofSeconds(20))
|
|
||||||
.build();
|
|
||||||
HttpRequest httpRequest = HttpRequest.newBuilder()
|
|
||||||
.GET()
|
|
||||||
.uri(URI.create("http://localhost:" + port))
|
|
||||||
.build();
|
|
||||||
HttpResponse<String> httpResponse = httpClient.send(httpRequest, HttpResponse.BodyHandlers.ofString());
|
|
||||||
assertThat(httpResponse.body()).isEqualTo("Hello from the server!");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue