Code Monkey home page Code Monkey logo

consume-soap-webservices-using-webservicetemplate's Introduction

WebserviceTemplate:

SOAPConnector class extends WebServiceGatewaySupport which basically injects one interface with internal implementation of WebServiceTemplate which is available by getWebServiceTemplate() method.

We will use this WebServiceTemplate to invoke the SOAP service.

This class also expects one injected spring bean called Marshaller and Unmarshallerwhich will be provided by a configuration class which we will see next.

pom.xml:

<plugin>
  <groupId>org.jvnet.jaxb2.maven2</groupId>
  <artifactId>maven-jaxb2-plugin</artifactId>
  <version>0.13.2</version>
  <executions>
    <execution>
      <goals>
        <goal>generate</goal>
      </goals>
    </execution>
  </executions>
  <configuration>
    <generatePackage>com.example.howtodoinjava.schemas.school</generatePackage>
    <generateDirectory>${project.basedir}/src/main/java</generateDirectory>
    <schemaDirectory>${project.basedir}/src/main/resources/wsdl</schemaDirectory>
    <schemaIncludes>
      <include>*.wsdl</include>
    </schemaIncludes>
  </configuration>
</plugin> 

SOAPConnector.java:


package com.example.howtodoinjava.springbootsoapclient;
 
import org.springframework.ws.client.core.support.WebServiceGatewaySupport;
 
public class SOAPConnector extends **WebServiceGatewaySupport** {
 
  public Object callWebService(String url, Object request){
    return getWebServiceTemplate().marshalSendAndReceive(url, request);
  }
}

configuration.java:


@configuration
public class config{

@Bean
public Jaxb2Marshaller marshaller(){

Jaxb2Marshaller marshaller = new Jaxb2Marshaller();

marshaller.setContextPath("com.example.howtodoinjava.schemas.school");

return marshaller;

}




consume-soap-webservices-using-webservicetemplate's People

Contributors

sandysanthosh avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.