package Ġorg . the la ugh ing dev . soap . server . web service Ċ Ċ import Ġorg . the la ugh ing dev . wsdl . Get Country Request Ċ import Ġorg . the la ugh ing dev . wsdl . Get Country Response Ċ import Ġorg . springframework . beans . factory . annotation . Autowired Ċ import Ġorg . springframework . ws . server . endpoint . annotation . Endpoint Ċ import Ġorg . springframework . ws . server . endpoint . annotation . Payload Root Ċ import Ġorg . springframework . ws . server . endpoint . annotation . Request Payload Ċ import Ġorg . springframework . ws . server . endpoint . annotation . Response Payload Ċ import Ġorg . the la ugh ing dev . soap . server . repository . Country Repository Ċ import Ġorg . the la ugh ing dev . wsdl . Find Country ByName Request Ċ import Ġorg . the la ugh ing dev . wsdl . GetAll Countries Response Ċ Ċ /** Ċ Ġ* ĠDefines Ġendpoints Ġweb Ġservices . Ċ Ġ*/ Ċ @ Endpoint Ċ open Ġclass ĠCountry Endpoint Ġ@ Autowired Ġconstructor ( private Ġval Ġcountry Repository : ĠCountry Repository ) Ġ{ ĊĊ ĉ comp anion Ġobject Ġ{ Ċĉ ĉ const Ġval ĠNAMES PACE _ URI Ġ= Ġ" http :// the la ugh ing dev . org / web - services " Ċ ĉ } ĊĊ ĉ @ Payload Root ( namespace Ġ= ĠNAMES PACE _ URI , Ġlocal Part Ġ= Ġ" getAll Countries ") Ċ ĉ @ Response Payload Ċ ĉ fun ĠgetAll Countries (): ĠGetAll Countries Response Ġ{ Ċĉ ĉ return ĠGetAll Countries Response (). apply Ġ{ Ċĉĉ ĉ country Repository . findAll (). map { it . to Dto ()}. forEach Ġ{ countries . add ( it )}; Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ @ Payload Root ( namespace Ġ= ĠNAMES PACE _ URI , Ġlocal Part Ġ= Ġ" get Country Request ") Ċ ĉ @ Response Payload Ċ ĉ fun Ġget Country (@ Request Payload Ġrequest : ĠGet Country Request ): ĠGet Country Response Ġ{ Ċĉ ĉ val Ġresponse Ġ= ĠGet Country Response (). apply Ġ{ Ċĉĉ ĉ country Ġ= Ġcountry Repository . findById ( request . id ). orElse Throw Ġ{ ĠException (" Can 't Ġfind Ġcountry Ġfor Ġid Ġ${ request . id }") Ġ}. to Dto () Ċĉ ĉ } Ċĉ ĉ return Ġresponse Ċ ĉ } ĊĊ ĉ @ Payload Root ( namespace Ġ= ĠNAMES PACE _ URI , Ġlocal Part Ġ= Ġ" find Country ByName Request ") Ċ ĉ @ Response Payload Ċ ĉ fun Ġfind Country ByName Request (@ Request Payload Ġrequest : ĠFind Country ByName Request ): ĠGet Country Response Ġ{ Ċĉ ĉ val Ġresponse Ġ= ĠGet Country Response (). apply Ġ{ Ċĉĉ ĉ country Ġ= Ġcountry Repository . find ByName ( request . name )?. to Dto () Ġ?: Ġthrow ĠException (" Can 't Ġfind Ġcountry Ġfor Ġname Ġ${ request . name }") Ċĉ ĉ } Ċĉ ĉ return Ġresponse Ċ ĉ } Ċ }