title: java.lang.IllegalStateException: No unmarshaller registered. Check configuration of WebServiceTemplate
body: <p>When I send a SOAP request to the server it returns following error. I am not sure how I can configure unmarshaller, I am going to send SOAP requests to multiple webservices. <strong>WSDL</strong> is <a href="http://www5v80.elsyarres.net/service.asmx?wsdl" rel="noreferrer">here</a>.</p>
  
  <p>I visited following pages but could not find a solution yet. <a href="https://stackoverflow.com/questions/27865057/jibx-classes-generated-from-maven-codegen-plugin-no-unmarshaller-for-element">1</a>,<a href="https://stackoverflow.com/questions/6189601/injection-of-property-in-xml-fails-spring-ws-config">2</a>,<a href="https://stackoverflow.com/questions/29597543/java-lang-illegalstateexception-no-scope-registered-for-scope-session">3</a></p>
  
  <pre><code> java.lang.IllegalStateException: No unmarshaller registered. Check configuration of WebServiceTemplate.
      at org.springframework.ws.client.core.WebServiceTemplate$3.extractData(WebServiceTemplate.java:406)
      at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:598)
      at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:539)
      at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:386)
  </code></pre>
  
  <p><strong>Code</strong></p>
  
  <p>SearchFlights</p>
  
  <pre><code>@XmlRootElement(name = "SearchFlights")
  @XmlAccessorType(XmlAccessType.FIELD)
  public class SearchFlights {
      @XmlElement(name = "SoapMessage")
      private SoapMessage soapMessage;
  
      getter and setter
  </code></pre>
  
  <p>SoapMessage</p>
  
  <pre><code>@XmlRootElement(name = "SoapMessage")
  @XmlAccessorType(XmlAccessType.FIELD)
  public class SoapMessage {
      @XmlElement(name = "Username")
      private String username;
      @XmlElement(name = "Password")
      private String password;
      @XmlElement(name = "LanguageCode")
      private String languageCode;
      @XmlElement(name = "Request")
      private Request request;
  
      getters and setters
  </code></pre>
  
  <p>Request</p>
  
  <pre><code>@XmlRootElement(name = "Request")
  @XmlAccessorType(XmlAccessType.FIELD)
  public class Request {
      @XmlElement(name = "Departure")
      private String departure;
      @XmlElement(name = "Destination")
      private String destination;
      @XmlElement(name = "DepartureDate")
      private String departureDate;
      @XmlElement(name = "ReturnDate")
      private String returnDate;
      @XmlElement(name = "NumADT")
      private int numADT;
      @XmlElement(name = "NumINF")
      private int numInf;
      @XmlElement(name = "NumCHD")
      private int numCHD;
      @XmlElement(name = "CurrencyCode")
      private String currencyCode;
      @XmlElement(name = "WaitForResult")
      private boolean waitForResult;
      @XmlElement(name = "NearByDepartures")
      private boolean nearByDepartures;
      @XmlElement(name = "NearByDestinations")
      private boolean nearByDestinations;
      @XmlElement(name = "RROnly")
      private boolean rronly;
      @XmlElement(name = "MetaSearch")
      private boolean metaSearch;
  
  getters and setters
  </code></pre>
  
  <p>jaxb.index</p>
  
  <pre><code>SearchFlights
  Flight
  Flights
  Leg
  Legs
  Outbound
  Request
  Response
  SoapMessage
  </code></pre>
  
  <p><strong>Code to send request</strong></p>
  
  <pre><code>import javax.xml.soap.MessageFactory;
  import javax.xml.soap.SOAPConstants;
  
  import org.springframework.oxm.jaxb.Jaxb2Marshaller;
  import org.springframework.stereotype.Service;
  import org.springframework.web.client.RestClientException;
  import org.springframework.web.client.RestTemplate;
  import org.springframework.ws.client.core.WebServiceTemplate;
  import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;
  ......
      // populate searchFlights and other classes to create request
      try {
          SaajSoapMessageFactory messageFactory = new SaajSoapMessageFactory(
                  MessageFactory.newInstance());
          messageFactory.afterPropertiesSet();
  
          WebServiceTemplate webServiceTemplate = new WebServiceTemplate(
                  messageFactory);
          Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
  
          marshaller.setContextPath("com.myproject.flights.wegolo");
          marshaller.afterPropertiesSet();
  
          webServiceTemplate.setMarshaller(marshaller);
          webServiceTemplate.afterPropertiesSet();
  
  
  
              Response response = (Response) webServiceTemplate
                              .marshalSendAndReceive(   &lt;&lt;&lt; ERROR is on this line
                                   "http://www5v80.elsyarres.net/service.asmx",
                                    searchFlights,
                                    new WebServiceMessageCallback() {
                                       public void doWithMessage(WebServiceMessage message) 
                                          {
  
                       ((SoapMessage)message).setSoapAction("http://www5v80.elsyarres.net/searchFlights");
                                          }
                                     }
                                 );
              Response msg = (Response) response;
              System.err.println("Wegolo &gt;&gt;&gt;"
                      + msg.getFlights().getFlight().size());
          } catch (Exception s) {
              s.printStackTrace();
          }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/wdrHF.png" rel="noreferrer"><img src="https://i.stack.imgur.com/wdrHF.png" alt="enter image description here"></a></p>