복붙노트

[SPRING] java.lang.IllegalStateException : 등록되어있는 비 정렬 화기가 없습니다. WebServiceTemplate의 구성을 확인하십시오.

SPRING

java.lang.IllegalStateException : 등록되어있는 비 정렬 화기가 없습니다. WebServiceTemplate의 구성을 확인하십시오.

서버에 SOAP 요청을 보내면 다음 오류가 반환됩니다. 어떻게 unmarshaller를 구성 할 수 있는지 잘 모르겠습니다. SOAP 요청을 여러 웹 서비스로 보냅니다. WSDL이 여기에 있습니다.

다음 페이지를 방문했지만 아직 해결책을 찾을 수 없습니다. 1,2,3

 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)

암호

항공편 검색

@XmlRootElement(name = "SearchFlights")
@XmlAccessorType(XmlAccessType.FIELD)
public class SearchFlights {
    @XmlElement(name = "SoapMessage")
    private SoapMessage soapMessage;

    getter and setter

SoapMessage

@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

의뢰

@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

jaxb.index

SearchFlights
Flight
Flights
Leg
Legs
Outbound
Request
Response
SoapMessage

요청을 보내는 코드

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(   <<< 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 >>>"
                    + msg.getFlights().getFlight().size());
        } catch (Exception s) {
            s.printStackTrace();
        }

해결법

  1. ==============================

    1.webServiceTemplate에서 unmarshaller를 설정하지 않은 것으로 보입니다.

    webServiceTemplate에서 unmarshaller를 설정하지 않은 것으로 보입니다.

    webServiceTemplate.setMarshaller(marshaller);
    webServiceTemplate.setUnmarshaller(marshaller);
    
  2. from https://stackoverflow.com/questions/34765744/java-lang-illegalstateexception-no-unmarshaller-registered-check-configuration by cc-by-sa and MIT license