// Path: step3_jaxws-endpoint-cxf-spring-boot/src/main/java/de/jonashackt/tutorial/endpoint/WeatherServiceEndpoint.java
// public class WeatherServiceEndpoint implements WeatherService {
// 
//     @Override
//     public ForecastReturn getCityForecastByZIP(ForecastRequest forecastRequest)
//             throws WeatherException {
//         // TODO Auto-generated method stub
//         return null;
//     }
//     
//     @Override
//     public WeatherInformationReturn getWeatherInformation(String zip)
//             throws WeatherException {
//         // TODO Auto-generated method stub
//         return null;
//     }
// 
//     @Override
//     public WeatherReturn getCityWeatherByZIP(ForecastRequest forecastRequest)
//             throws WeatherException {
//         // TODO Auto-generated method stub
//         return null;
//     }
// 
// }
// 
// Path: step9_soap_message_logging_into_custom_elasticsearch_field/src/main/java/de/jonashackt/tutorial/soapmsglogging/SoapMsgToMdcExtractionLoggingInInterceptor.java
// public class SoapMsgToMdcExtractionLoggingInInterceptor extends LoggingInInterceptor {
// 
//     private static final Logger LOG = LoggerFactory.getLogger(SoapMsgToMdcExtractionLoggingInInterceptor.class);
//     private static final String SOAP_MESSAGE_INBOUND = "soap-message-inbound";
// 
//     @Override
//     protected void log(java.util.logging.Logger logger, String message) {
//         // just do nothing, because we don´t want CXF-Implementation to log,
//         // we just want to Push the SOAP-Message to Logback -> Logstash -> Elasticsearch -> Kibana
//     }
// 
// 	@Override
//     protected String formatLoggingMessage(LoggingMessage loggingMessage) {
//         // Only write the Payload (SOAP-Xml) to Logger
//         if (loggingMessage.getPayload().length() > 0) {
//             LOG.info(append(SOAP_MESSAGE_INBOUND, loggingMessage.getPayload().toString()), "Log Inbound-SoapMessage to Elasticseach");
//         }
//         // This is just hook into CXF and get the SOAP-Message.
//         // The returned String will never be logged somewhere.
//         return "";
//     }
// 
// }
// 
// Path: step9_soap_message_logging_into_custom_elasticsearch_field/src/main/java/de/jonashackt/tutorial/soapmsglogging/SoapMsgToMdcExtractionLoggingOutInterceptor.java
// public class SoapMsgToMdcExtractionLoggingOutInterceptor extends LoggingOutInterceptor {
// 
//     private static final Logger LOG = LoggerFactory.getLogger(SoapMsgToMdcExtractionLoggingOutInterceptor.class);
//     private static final String SOAP_MESSAGE_OUTBOUND = "soap-message-outbound";
// 
//     @Override
//     protected void log(java.util.logging.Logger logger, String message) {
//         // just do nothing, because we don´t want CXF-Implementation to log,
//         // we just want to Push the SOAP-Message to Logback -> Logstash -> Elasticsearch -> Kibana
//     }
// 
//     @Override
//     protected String formatLoggingMessage(LoggingMessage loggingMessage) {
//         // Only write the Payload (SOAP-Xml) to Logger
//         if (loggingMessage.getPayload().length() > 0) {
//             LOG.info(append(SOAP_MESSAGE_OUTBOUND, loggingMessage.getPayload().toString()), "Log Outbound-SoapMessage to Elasticseach");
//         }
//         // This is just hook into CXF and get the SOAP-Message.
//         // The returned String will never be logged somewhere.
//         return "";
//     }
// }


import de.codecentric.namespace.weatherservice.Weather;
import de.codecentric.namespace.weatherservice.WeatherService;
import de.jonashackt.tutorial.endpoint.WeatherServiceEndpoint;
import de.jonashackt.tutorial.soapmsglogging.SoapMsgToMdcExtractionLoggingInInterceptor;
import de.jonashackt.tutorial.soapmsglogging.SoapMsgToMdcExtractionLoggingOutInterceptor;
import org.apache.cxf.Bus;
import org.apache.cxf.bus.spring.SpringBus;
import org.apache.cxf.interceptor.AbstractLoggingInterceptor;
import org.apache.cxf.interceptor.LoggingInInterceptor;
import org.apache.cxf.interceptor.LoggingOutInterceptor;
import org.apache.cxf.jaxws.EndpointImpl;
import org.apache.cxf.transport.servlet.CXFServlet;
import org.springframework.boot.context.embedded.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.xml.ws.Endpoint;
    }
    
    @Bean
    public Endpoint endpoint() {
        EndpointImpl endpoint = new EndpointImpl(springBus(), weatherService());        
        // CXF JAX-WS implementation relies on the correct ServiceName as QName-Object with
        // the name-Attribute´s text <wsdl:service name="Weather"> and the targetNamespace
        // "http://www.codecentric.de/namespace/weatherservice/"
        // Also the WSDLLocation must be set
        endpoint.setServiceName(weather().getServiceName());
        endpoint.setWsdlLocation(weather().getWSDLDocumentLocation().toString());
        endpoint.publish(SERVICE_URL);
        return endpoint;
    }
    
    @Bean
    public Weather weather() {
        // Needed for correct ServiceName & WSDLLocation to publish contract first incl. original WSDL
        return new Weather();
    }

    @Bean
    public AbstractLoggingInterceptor logInInterceptor() {
        LoggingInInterceptor logInInterceptor = new SoapMsgToMdcExtractionLoggingInInterceptor();
        logInInterceptor.setPrettyLogging(true);
        return logInInterceptor;
    }

    @Bean
    public AbstractLoggingInterceptor logOutInterceptor() {
// Path: step3_jaxws-endpoint-cxf-spring-boot/src/main/java/de/jonashackt/tutorial/endpoint/WeatherServiceEndpoint.java
// public class WeatherServiceEndpoint implements WeatherService {
// 
//     @Override
//     public ForecastReturn getCityForecastByZIP(ForecastRequest forecastRequest)
//             throws WeatherException {
//         // TODO Auto-generated method stub
//         return null;
//     }
//     
//     @Override
//     public WeatherInformationReturn getWeatherInformation(String zip)
//             throws WeatherException {
//         // TODO Auto-generated method stub
//         return null;
//     }
// 
//     @Override
//     public WeatherReturn getCityWeatherByZIP(ForecastRequest forecastRequest)
//             throws WeatherException {
//         // TODO Auto-generated method stub
//         return null;
//     }
// 
// }
// 
// Path: step9_soap_message_logging_into_custom_elasticsearch_field/src/main/java/de/jonashackt/tutorial/soapmsglogging/SoapMsgToMdcExtractionLoggingInInterceptor.java
// public class SoapMsgToMdcExtractionLoggingInInterceptor extends LoggingInInterceptor {
// 
//     private static final Logger LOG = LoggerFactory.getLogger(SoapMsgToMdcExtractionLoggingInInterceptor.class);
//     private static final String SOAP_MESSAGE_INBOUND = "soap-message-inbound";
// 
//     @Override
//     protected void log(java.util.logging.Logger logger, String message) {
//         // just do nothing, because we don´t want CXF-Implementation to log,
//         // we just want to Push the SOAP-Message to Logback -> Logstash -> Elasticsearch -> Kibana
//     }
// 
// 	@Override
//     protected String formatLoggingMessage(LoggingMessage loggingMessage) {
//         // Only write the Payload (SOAP-Xml) to Logger
//         if (loggingMessage.getPayload().length() > 0) {
//             LOG.info(append(SOAP_MESSAGE_INBOUND, loggingMessage.getPayload().toString()), "Log Inbound-SoapMessage to Elasticseach");
//         }
//         // This is just hook into CXF and get the SOAP-Message.
//         // The returned String will never be logged somewhere.
//         return "";
//     }
// 
// }
// 
// Path: step9_soap_message_logging_into_custom_elasticsearch_field/src/main/java/de/jonashackt/tutorial/soapmsglogging/SoapMsgToMdcExtractionLoggingOutInterceptor.java
// public class SoapMsgToMdcExtractionLoggingOutInterceptor extends LoggingOutInterceptor {
// 
//     private static final Logger LOG = LoggerFactory.getLogger(SoapMsgToMdcExtractionLoggingOutInterceptor.class);
//     private static final String SOAP_MESSAGE_OUTBOUND = "soap-message-outbound";
// 
//     @Override
//     protected void log(java.util.logging.Logger logger, String message) {
//         // just do nothing, because we don´t want CXF-Implementation to log,
//         // we just want to Push the SOAP-Message to Logback -> Logstash -> Elasticsearch -> Kibana
//     }
// 
//     @Override
//     protected String formatLoggingMessage(LoggingMessage loggingMessage) {
//         // Only write the Payload (SOAP-Xml) to Logger
//         if (loggingMessage.getPayload().length() > 0) {
//             LOG.info(append(SOAP_MESSAGE_OUTBOUND, loggingMessage.getPayload().toString()), "Log Outbound-SoapMessage to Elasticseach");
//         }
//         // This is just hook into CXF and get the SOAP-Message.
//         // The returned String will never be logged somewhere.
//         return "";
//     }
// }


// Path: step9_soap_message_logging_into_custom_elasticsearch_field/src/main/java/de/jonashackt/tutorial/configuration/WebServiceConfiguration.java
import de.codecentric.namespace.weatherservice.Weather;
import de.codecentric.namespace.weatherservice.WeatherService;
import de.jonashackt.tutorial.endpoint.WeatherServiceEndpoint;
import de.jonashackt.tutorial.soapmsglogging.SoapMsgToMdcExtractionLoggingInInterceptor;
import de.jonashackt.tutorial.soapmsglogging.SoapMsgToMdcExtractionLoggingOutInterceptor;
import org.apache.cxf.Bus;
import org.apache.cxf.bus.spring.SpringBus;
import org.apache.cxf.interceptor.AbstractLoggingInterceptor;
import org.apache.cxf.interceptor.LoggingInInterceptor;
import org.apache.cxf.interceptor.LoggingOutInterceptor;
import org.apache.cxf.jaxws.EndpointImpl;
import org.apache.cxf.transport.servlet.CXFServlet;
import org.springframework.boot.context.embedded.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.xml.ws.Endpoint;

    }
    
    @Bean
    public Endpoint endpoint() {
        EndpointImpl endpoint = new EndpointImpl(springBus(), weatherService());        
        // CXF JAX-WS implementation relies on the correct ServiceName as QName-Object with
        // the name-Attribute´s text <wsdl:service name="Weather"> and the targetNamespace
        // "http://www.codecentric.de/namespace/weatherservice/"
        // Also the WSDLLocation must be set
        endpoint.setServiceName(weather().getServiceName());
        endpoint.setWsdlLocation(weather().getWSDLDocumentLocation().toString());
        endpoint.publish(SERVICE_URL);
        return endpoint;
    }
    
    @Bean
    public Weather weather() {
        // Needed for correct ServiceName & WSDLLocation to publish contract first incl. original WSDL
        return new Weather();
    }

    @Bean
    public AbstractLoggingInterceptor logInInterceptor() {
        LoggingInInterceptor logInInterceptor = new SoapMsgToMdcExtractionLoggingInInterceptor();
        logInInterceptor.setPrettyLogging(true);
        return logInInterceptor;
    }

    @Bean
    public AbstractLoggingInterceptor logOutInterceptor() {
        LoggingOutInterceptor logOutInterceptor = new SoapMsgToMdcExtractionLoggingOutInterceptor();