{"id":4304,"date":"2020-08-11T16:02:05","date_gmt":"2020-08-11T10:32:05","guid":{"rendered":"https:\/\/www.h2kinfosys.com\/blog\/?p=4304"},"modified":"2020-08-25T16:29:54","modified_gmt":"2020-08-25T10:59:54","slug":"what-is-the-top-down-bottom-up-approach","status":"publish","type":"post","link":"https:\/\/www.h2kinfosys.com\/blog\/what-is-the-top-down-bottom-up-approach\/","title":{"rendered":"What is the Top-Down Bottom-up Approach?"},"content":{"rendered":"\n<p>Web Services can be implemented using two approaches top-down bottom-up Approach:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Top-Down<\/li><li>Bottom-up<\/li><\/ol>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Top-Down: <\/strong><\/h2>\n\n\n\n<p>In Top-down Approach, the service contract that is WSDL is defined first. Thus, this approach is also known as the contract-first approach. WSDL contains all the information regarding the service, such as service definition, message format, security details, etc. Here the WSDL&nbsp; is written fist and then the service code.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/3AgCTmm8-4e0gMSumL6hhtHZzHKak3Af42EHJF5An3iVlPzSdJx76_FnbCG1lv7U0KW6euNpi6SSYUspjTdlbRefJVHMvV6FsO9mKh-FQNytXl1T12sW4BLIxngWGh30HrVhUYxEuWRDgnveZQ\" alt=\"TopDown Approach\" title=\"\"><\/figure><\/div>\n\n\n\n<p>Let us implement the Top-down approach.&nbsp;<\/p>\n\n\n\n<p><strong>Step 1: <\/strong>Create <a href=\"https:\/\/www.h2kinfosys.com\/blog\/maven-jenkins-integration-with-selenium\/\">Maven Dependencies<\/a>.<\/p>\n\n\n\n<p>First, add the spring-boot-starter-parent to your project.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;parent&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;artifactId&gt;spring-boot-starter-parent&lt;\/artifactId&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;version&gt;2.2.6.RELEASE&lt;\/version&gt;\n&lt;\/parent&gt;\nThen, add the spring-boot-starter-web-services and wsdl4j dependencies.\n&lt;dependency&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;artifactId&gt;spring-boot-starter-web-services&lt;\/artifactId&gt;\n&lt;\/dependency&gt;\n&lt;dependency&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;groupId&gt;wsdl4j&lt;\/groupId&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;artifactId&gt;wsdl4j&lt;\/artifactId&gt;\n&lt;\/dependency&gt;\n<\/pre>\n\n\n\n<p><strong>Step 2: <\/strong>Create XSD File<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;xs:schema xmlns:xs=\"https:\/\/www.w3.org\/2001\/XMLSchema\" xmlns:tns=\"https:\/\/www.example.com\/springsoap\/gen\"\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;targetNamespace=\"http:\/\/www.example.com\/springsoap\/gen\" elementFormDefault=\"qualified\"&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;xs:element name=\"getCountryRequest\"&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;xs:complexType&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;xs:sequence&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;xs:element name=\"name\" type=\"xs:string\"\/&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/xs:sequence&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/xs:complexType&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/xs:element&gt;\n&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;xs:element name=\"getCountryResponse\"&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;xs:complexType&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;xs:sequence&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;xs:element name=\"country\" type=\"tns:country\"\/&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/xs:sequence&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/xs:complexType&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/xs:element&gt;\n&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;xs:complexType name=\"country\"&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;xs:sequence&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;xs:element name=\"name\" type=\"xs:string\"\/&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;xs:element name=\"population\" type=\"xs:int\"\/&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;xs:element name=\"capital\" type=\"xs:string\"\/&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;xs:element name=\"currency\" type=\"tns:currency\"\/&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/xs:sequence&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/xs:complexType&gt;\n&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;xs:simpleType name=\"currency\"&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;xs:restriction base=\"xs:string\"&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;xs:enumeration value=\"GBP\"\/&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;xs:enumeration value=\"EUR\"\/&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;xs:enumeration value=\"PLN\"\/&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/xs:restriction&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/xs:simpleType&gt;\n&lt;\/xs:schema&gt;<\/pre>\n\n\n\n<p><strong>Step 3: <\/strong>We will now generate the Java classes from the XSD file defined. The jaxb2-maven-plugin uses the XJC tool as code generation engine, and XJC compiles the XSD schema file into fully annotated Java classes.<\/p>\n\n\n\n<p>We will add and configure the plugin in our <strong>pom.xml.<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;plugin&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;groupId&gt;org.codehaus.mojo&lt;\/groupId&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;artifactId&gt;jaxb2-maven-plugin&lt;\/artifactId&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;version&gt;1.6&lt;\/version&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;executions&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;execution&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;id&gt;xjc&lt;\/id&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;goals&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;goal&gt;xjc&lt;\/goal&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/goals&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/execution&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/executions&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;configuration&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;schemaDirectory&gt;${project.basedir}\/src\/main\/resources\/&lt;\/schemaDirectory&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;outputDirectory&gt;${project.basedir}\/src\/main\/java&lt;\/outputDirectory&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;clearOutputDir&gt;false&lt;\/clearOutputDir&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/configuration&gt;\n&lt;\/plugin&gt;\n<\/pre>\n\n\n\n<p><strong>Step 4: <\/strong>Add the SOAP Web Service Endpoint<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">@Component\npublic class CountryRepository {\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;private static final Map&lt;String, Country&gt; countries = new HashMap&lt;&gt;();\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@PostConstruct\n&nbsp;&nbsp;&nbsp;&nbsp;public void initData() {\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/ initialize countries map\n&nbsp;&nbsp;&nbsp;&nbsp;}\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public Country findCountry(String name) {\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return countries.get(name);\n&nbsp;&nbsp;&nbsp;&nbsp;}\n}\n@Endpoint\npublic class CountryEndpoint {\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;private static final String NAMESPACE_URI = \"https:\/\/www.example.com\/springsoap\/gen\";\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;private CountryRepository countryRepository;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@Autowired\n&nbsp;&nbsp;&nbsp;&nbsp;public CountryEndpoint(CountryRepository countryRepository) {\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.countryRepository = countryRepository;\n&nbsp;&nbsp;&nbsp;&nbsp;}\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@PayloadRoot(namespace = NAMESPACE_URI, localPart = \"getCountryRequest\")\n&nbsp;&nbsp;&nbsp;&nbsp;@ResponsePayload\n&nbsp;&nbsp;&nbsp;&nbsp;public GetCountryResponse getCountry(@RequestPayload GetCountryRequest request) {\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;GetCountryResponse response = new GetCountryResponse();\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;response.setCountry(countryRepository.findCountry(request.getName()));\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return response;\n&nbsp;&nbsp;&nbsp;&nbsp;}\n}\n<\/pre>\n\n\n\n<p><strong>Step 5: <\/strong>Create SOAP Web Service Configuration Beans.<\/p>\n\n\n\n<p>First, create a class to configure the Spring message dispatcher servlet for receiving the request.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@EnableWs\n@Configuration\npublic class WebServiceConfig extends WsConfigurerAdapter {\n    \/\/ bean definitions\n}<\/code><\/pre>\n\n\n\n<p>@EnableWs will enable the <a href=\"https:\/\/www.h2kinfosys.com\/blog\/what-is-spring-web-service\/\">SOAP Web Service<\/a> features in this Spring Boot application. The WebServiceConfig class will then extend the WsConfigurerAdapter base class, which configures the annotation-driven Spring-WS programming model.<\/p>\n\n\n\n<p>Now create a MessageDispatcherServlet, which is used for handling SOAP requests.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@Bean\npublic ServletRegistrationBean messageDispatcherServlet(ApplicationContext applicationContext) {\n    MessageDispatcherServlet servlet = new MessageDispatcherServlet();\n    servlet.setApplicationContext(applicationContext);\n    servlet.setTransformWsdlLocations(true);\n    return new ServletRegistrationBean(servlet, \"\/ws\/*\");\n}<\/code><\/pre>\n\n\n\n<p>Finally, we will create a DefaultWsdl11Definition object that exposes a <a href=\"https:\/\/en.wikipedia.org\/wiki\/Web_Services_Description_Language\" rel=\"nofollow noopener\" target=\"_blank\">standard WSDL<\/a> using an XsdSchema. The WSDL name will be the same as of the bean name.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">@Bean(name = \"countries\")\npublic DefaultWsdl11Definition defaultWsdl11Definition(XsdSchema countriesSchema) {\n&nbsp;&nbsp;&nbsp;&nbsp;DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition();\n&nbsp;&nbsp;&nbsp;&nbsp;wsdl11Definition.setPortTypeName(\"CountriesPort\");\n&nbsp;&nbsp;&nbsp;&nbsp;wsdl11Definition.setLocationUri(\"\/ws\");\n&nbsp;&nbsp;&nbsp;&nbsp;wsdl11Definition.setTargetNamespace(\"http:\/\/www.example.com\/springsoap\/gen\");\n&nbsp;&nbsp;&nbsp;&nbsp;wsdl11Definition.setSchema(countriesSchema);\n&nbsp;&nbsp;&nbsp;&nbsp;return wsdl11Definition;\n}\n&nbsp;@Bean\npublic XsdSchema countriesSchema() {\n&nbsp;&nbsp;&nbsp;&nbsp;return new SimpleXsdSchema(new ClassPathResource(\"countries.xsd\"));\n}<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Bottom-Up: <\/strong><\/h2>\n\n\n\n<p>This approach is exactly the reverse of the Top-down Approach. In this approach, WSDL is created last. Thus, this approach is also known as the contract-last approach. Here the service code is written fist and then the WSDL.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/_N4cU7MTMzDF3RVQXOQbdJz9I-pmUGnomIjq97vGlNMUIUrtaoqllXlcZVHdCUS0JRhAOFHVZvGMq3fryEa-zPCLNHngyLOMs6JqHdGMe2f6hYcceRDJ6RXkqOza0MxM3Jx9EwNu3bDvWmgylg\" alt=\"BottomUp Approach\" title=\"\"><\/figure>\n\n\n\n<p>Let us implement the Bottom-up approach.<\/p>\n\n\n\n<p><strong>Step 1: <\/strong>Create a maven project.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/mGaw_7GLJ4gsJBjDLcwYlo6MuKP6TzYO5bhuEB1QcYa6mTMaxvhmYVWe2gpLFj8iJp7jZOFdy_f6jWJ6OjME6ac6qHtPE6xnUjO7UrgASeVapVpXkkpAZRagVTfs0kZBHVmNKskBOiOAIOn6Tw\" alt=\"Fig - New Maven project \" title=\"\"><\/figure>\n\n\n\n<p>Provide the details about the maven project.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/JXKgxXBcn12z_dYEQT3QPPCmMe9nncfD5uZTaosOTdF0K2cJ2waYfjqq6JWDBm0l_V0lr-HzlruehtzARGj_k7h-cIZER9W18yWi2yqFxdzGY3mtG7Xv2y6kxXml0eRsUJVdK5dBvzpF0dgBXQ\" alt=\"Fig - Creating New Maven Project\" title=\"\"><\/figure>\n\n\n\n<p>Select the maven-archetype-web app and click on Next.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/6OdR4eEzdsvT3UXPt-_V6r-IL9Nr9Q4-Xyg-qpLQdIDkZ6Bs_0DcERI6AU76okaDy4nXkiKg7dbtfXpVcdDuY0BTXZZJYMa4ETn7NBP9HV9hpH737RuL5uuiI8n9S6DbyvC-YuYCYm1gkaa1Pg\" alt=\"Fig - select maven-archetype-web app \" title=\"\"><\/figure>\n\n\n\n<p>Fill the fields, and click on the Finish button.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/IzHOfXNgiTSClu3QD26gkkYOxKDURuQOTV9izY6gjnYvO3FX8XLSNdwuGZQ4Y_h0n5RWVbzPKnr-c1mEHBpMQKApL4noXlVMOCXpXVitUFfCpgOSSTZ4RQfqHDFUJQCZUWf6ouOlNbbGvjqfxA\" alt=\"Fig - Provide Group Id, Artifact Id, version and Package information \" title=\"\"><\/figure>\n\n\n\n<p><strong>Step 2: <\/strong>Default POM file will get generated.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/iH7qTPsjyIrXcJbXV_MQyL0fHlWlVrPOxGhnd63RjukiD5tpIh6eTKP-Gd6A_opWCilFr0qoonTRjmIKmc4i7AzfOHXvNGeV-psx1381Fw-D4xKAaUVLlzwH6VVpskcPveyNk19A5dSQ__i0JQ\" alt=\"Fig - default POM file generated \" title=\"\"><\/figure>\n\n\n\n<p>Add the below jars as a dependency.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Spring-core<\/li><li>Spring-web<\/li><li>Spring-context<\/li><li>cxf-rt-frontend-jaxws<\/li><li>Cxf-Rt-transports-http<\/li><\/ul>\n\n\n\n<p><strong>Step 3: <\/strong>Define the POJO class.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/Xvud9zo6yE489GV4Ui-2wwrrBH_GPkz9-bq2c5GQ_lzrvxVGDeZKnEVeEiJi4z3-KlwdqyzuwNHAK7T91ilP7HXmEfFoKuF-WxS0m8DhmfOj0C5L5QIQjhPTzxg5QJO4ZdVE0EAktCpXTUIaYA\" alt=\"Fig - Define POJO class\" title=\"\"><\/figure>\n\n\n\n<p>Declare the methods in an interface.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/gKqyvpJ0kJrjv1Tmilm3TGJImTGMLT1L4or1s-wWEujHP_5Af6WMI1tLE5MsuMgYfQPv-qHrMG3s9QFpdmz-4nOKhqeJ6yd5bYgEIoXtp7ZOaj2x6dheTHUTfm6idl9ohDbQlJrFxABi6NmI_g\" alt=\"Define methods in Interface\" title=\"\"><\/figure>\n\n\n\n<p>Provide Class implementation.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/cdKJcQG2YFa6ywGyAvaNAe8UXg8rTV6dNrT-FldBR2Hty1HpnEYRDPvRmnRS7EUp-PFfYm5fOWAUZKeXddTbibGZ0kTUuH7cUWN2tGTDitzQyK_aVO3axONmWD4Sh_w09kY9FSS6pNT22VqQCw\" alt=\"Fig - class implementation for the interface\" title=\"\"><\/figure>\n\n\n\n<p>Define cxf bean in XML file and declare this file in web.xml.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/lhjhfWcw706DWnPIr2z9SVLYnkmMXO3_sYRRN_HqQWV4vNh93c7qZ4SKvvE-q2oQTmLDT1xB4jMHVYs1pdQswF4_eHo3Gw56Az3CIN8wmA-HR5iL2xHs7gLqDab_AM94fGmQS3qbAvCYfc_GSQ\" alt=\"Fig - endpoint implementation of the web service\" title=\"\"><\/figure>\n\n\n\n<p>Listing of web.xml is shown as:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/34-CelEOVv5sWkmmxdEESD5-OHLHkzOv9IAF1ViTnAsWLnwzCGaihESLEXBGoWRVl4HL2jIoVp4JCzYb6FdUD0FWWKCmpH-s6zAXatdNHld6EabaGRhm18GmSfji3nOJ9JNXR1BJ1HEpbwiRFA\" alt=\"Fig - The cxf servlet is mapped to url pattern as services\" title=\"\"><\/figure>\n\n\n\n<p><strong>Step 4: <\/strong>Deploy the web service using the below URL:<\/p>\n\n\n\n<p><em><span class=\"has-inline-color has-cyan-bluish-gray-color\">http:\/\/localhost:8080\/CustomerService\/services\/<\/span><\/em><\/p>\n\n\n\n<p>The page will display the details about the service:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/PTYQzUuSbmueJj0B0oiEOTzaCv6MAZN82VUeQNcjrtAqqcy2WQqsEjJJrkLOTANc2598zUgWGs2Dgpg91YTTUysqrK-fIoBEP73FZdfZ4JKN5_SrjdgL11HpBdS5sdefTnVkYuOv9fprB5G8pA\" alt=\"Fig - Service and the link to get WSDL file\" title=\"\"><\/figure>\n\n\n\n<p>The generated WSDL file will be:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;wsdl:definitions xmlns:xsd=\"http:\/\/www.w3.org\/2001\/XMLSchema\" xmlns:wsdl=\"http:\/\/schemas.xmlsoap.org\/wsdl\/\" xmlns:tns=\"http:\/\/cxf.ws.example.com\/\"xmlns:soap=\"http:\/\/schemas.xmlsoap.org\/wsdl\/soap\/\" xmlns:ns1=\"http:\/\/schemas.xmlsoap.org\/soap\/http\" name=\"CustomerServiceImplService\" targetNamespace=\"http:\/\/cxf.ws.example.com\/\"&gt;&nbsp;\n&lt;wsdl:types&gt;&nbsp;\n&lt;xs:schema xmlns:xs=\"http:\/\/www.w3.org\/2001\/XMLSchema\" xmlns:tns=\"http:\/\/cxf.ws.example.com\/\" elementFormDefault=\"unqualified\" targetNamespace=\"http:\/\/cxf.ws.example.com\/\"version=\"1.0\"&gt;\n&lt;xs:element name=\"addCustomer\" type=\"tns:addCustomer\"\/&gt;\n&lt;xs:element name=\"addCustomerResponse\" type=\"tns:addCustomerResponse\"\/&gt;&nbsp;\n&lt;xs:complexType name=\"addCustomer\"&gt;&nbsp;\n&lt;xs:sequence&gt;\n&lt;xs:element minOccurs=\"0\" name=\"arg0\" type=\"tns:customerVO\"\/&gt;\n&lt;\/xs:sequence&gt;a&nbsp;\n&lt;\/xs:complexType&gt;&nbsp;\n&lt;xs:complexType name=\"customerVO\"&gt;&nbsp;\n&lt;xs:sequence&gt;\n&lt;xs:element name=\"custId\" type=\"xs:int\"\/&gt;\n&lt;xs:element minOccurs=\"0\" name=\"custName\" type=\"xs:string\"\/&gt;\n&lt;\/xs:sequence&gt;&nbsp;\n&lt;\/xs:complexType&gt;&nbsp;\n&lt;xs:complexType name=\"addCustomerResponse\"&gt;&nbsp;\n&lt;xs:sequence&gt;\n&lt;xs:element minOccurs=\"0\" name=\"return\" type=\"xs:string\"\/&gt;\n&lt;\/xs:sequence&gt;&nbsp;\n&lt;\/xs:complexType&gt;&nbsp;\n&lt;\/xs:schema&gt;&nbsp;\n&lt;\/wsdl:types&gt;&nbsp;\n&lt;wsdl:message name=\"addCustomerResponse\"&gt;\n&lt;wsdl:part element=\"tns:addCustomerResponse\" name=\"parameters\"&gt;&lt;\/wsdl:part&gt;\n&lt;\/wsdl:message&gt;&nbsp;\n&lt;wsdl:message name=\"addCustomer\"&gt;\n&lt;wsdl:part element=\"tns:addCustomer\" name=\"parameters\"&gt;&lt;\/wsdl:part&gt;\n&lt;\/wsdl:message&gt;&nbsp;\n&lt;wsdl:portType name=\"ICustomerService\"&gt;&nbsp;\n&lt;wsdl:operation name=\"addCustomer\"&gt;\n&lt;wsdl:input message=\"tns:addCustomer\" name=\"addCustomer\"&gt;&lt;\/wsdl:input&gt;\n&lt;wsdl:output message=\"tns:addCustomerResponse\" name=\"addCustomerResponse\"&gt;&lt;\/wsdl:output&gt;\n&lt;\/wsdl:operation&gt;&nbsp;\n&lt;\/wsdl:portType&gt;&nbsp;\n&lt;wsdl:binding name=\"CustomerServiceImplServiceSoapBinding\" type=\"tns:ICustomerService\"&gt;\n&lt;soap:binding style=\"document\" transport=\"http:\/\/schemas.xmlsoap.org\/soap\/http\"\/&gt;&nbsp;\n&lt;wsdl:operation name=\"addCustomer\"&gt;\n&lt;soap:operation soapAction=\"\" style=\"document\"\/&gt;&nbsp;\n&lt;wsdl:input name=\"addCustomer\"&gt;\n&lt;soap:body use=\"literal\"\/&gt;\n&lt;\/wsdl:input&gt;&nbsp;\n&lt;wsdl:output name=\"addCustomerResponse\"&gt;\n&lt;soap:body use=\"literal\"\/&gt;\n&lt;\/wsdl:output&gt;&nbsp;\n&lt;\/wsdl:operation&gt;&nbsp;\n&lt;\/wsdl:binding&gt;&nbsp;\n&lt;wsdl:service name=\"CustomerServiceImplService\"&gt;\n&lt;wsdl:port binding=\"tns:CustomerServiceImplServiceSoapBinding\" name=\"CustomerServiceImplPort\"&gt;\n&lt;soap:address location=\"http:\/\/localhost:8080\/CustomerService\/services\/CustomerServiceImpl\"\/&gt;\n&lt;\/wsdl:port&gt;\n&lt;\/wsdl:service&gt;\n&lt;\/wsdl:definitions&gt;<\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Web Services can be implemented using two approaches top-down bottom-up Approach: Top-Down Bottom-up Top-Down: In Top-down Approach, the service contract that is WSDL is defined first. Thus, this approach is also known as the contract-first approach. WSDL contains all the information regarding the service, such as service definition, message format, security details, etc. Here the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":4323,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[42],"tags":[637,1195,1194],"class_list":["post-4304","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java-tutorials","tag-approach","tag-bottom-up","tag-top-down"],"_links":{"self":[{"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/posts\/4304","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/comments?post=4304"}],"version-history":[{"count":0,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/posts\/4304\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/media\/4323"}],"wp:attachment":[{"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/media?parent=4304"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/categories?post=4304"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/tags?post=4304"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}