This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static <T> String getNamespaceUriFromJaxbClass(Class<T> jaxbClass) { | |
String nsURI = ""; | |
for(Annotation annotation: jaxbClass.getPackage().getAnnotations()){ | |
if(annotation.annotationType() == XmlSchema.class){ | |
nsURI = ((XmlSchema)annotation).namespace(); | |
break; | |
} | |
} | |
return nsURI; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The inheritance of SpringBootServletInitializer is necessary for the war-Deployment-ability | |
@ComponentScan("de.codecentric.somepackage") | |
@EnableAutoConfiguration | |
@Configuration | |
public class Application extends SpringBootServletInitializer { | |
private static Class<Application> applicationClass = Application.class; | |
@Override | |
protected SpringApplicationBuilder configure(SpringApplicationBuilder applicationBuilder) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<packaging>war</packaging> | |
... | |
<dependency> | |
<groupId>org.springframework.boot</groupId> | |
<artifactId>spring-boot-starter-tomcat</artifactId> | |
<version>${spring-boot-version}</version> | |
<!-- war/Tomcat-Deployment - change deployment from pom to war --> | |
<scope>provided</scope> | |
</dependency> | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
. ____ _ __ _ _ | |
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ | |
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ | |
\\/ ___)| |_)| | | | | || (_| | ) ) ) ) | |
' |____| .__|_| |_|_| |_\__, | / / / / | |
=========|_|==============|___/=/_/_/_/ | |
:: Spring Boot :: (v1.2.3.RELEASE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
______ ______ ______ __ __ __ ______ __ __ | |
/\ ___\ /\ __ \ /\ __ \ /\ \ /\ "-.\ \ /\ ___\ /\ \ _ \ \ | |
\ \ \____ \ \ \/\ \ \ \ \/\ \ \ \ \____ \ \ \-. \ \ \ __\ \ \ \/ ".\ \ | |
\ \_____\ \ \_____\ \ \_____\ \ \_____\ \ \_\\"\_\ \ \_____\ \ \__/".~\_\ | |
\/_____/ \/_____/ \/_____/ \/_____/ \/_/ \/_/ \/_____/ \/_/ \/_/ | |
__ __ __ ______ ______ ______ ______ ______ ______ __ __ __ ______ ______ | |
/\ "-./ \ /\ \ /\ ___\ /\ == \ /\ __ \ /\ ___\ /\ ___\ /\ == \ /\ \ / / /\ \ /\ ___\ /\ ___ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import static org.springframework.test.web.client.match.MockRestRequestMatchers.method; | |
import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo; | |
import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess; | |
import org.junit.Before; | |
import org.junit.Test; | |
import org.junit.runner.RunWith; | |
import org.springframework.boot.test.SpringApplicationConfiguration; | |
import org.springframework.http.HttpMethod; | |
import org.springframework.http.MediaType; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- ... --> | |
<wsdl:message name="WeatherException"> | |
<wsdl:part name="parameters" element="datatypes:WeatherException" /> | |
</wsdl:message> | |
<!-- ... --> | |
<wsdl:portType name="WeatherSoap"> | |
<wsdl:operation name="GetWeatherInformation"> | |
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">Gets Information for each WeatherID</wsdl:documentation> | |
<wsdl:input message="tns:GetWeatherInformationSoapIn"/> | |
<wsdl:output message="tns:GetWeatherInformationSoapOut"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class WeatherServiceXmlValidationInterceptor extends AbstractSoapInterceptor { | |
//... | |
public WeatherServiceXmlValidationInterceptor() { | |
super(Phase.PRE_STREAM); | |
} | |
@Override | |
public void handleMessage(SoapMessage soapMessage) throws Fault { | |
Fault fault = (Fault) soapMessage.getContent(Exception.class); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//... | |
private boolean containsFaultIndicatingNotSchemeCompliantXml(Throwable faultCause, String faultMessage) { | |
if(faultCause instanceof UnmarshalException | |
// 1.) If the root-Element of the SoapBody is syntactically correct, but not scheme-compliant, | |
// there is no UnmarshalException and we have to look for | |
// 2.) Missing / lead to Faults without Causes, but to Messages like "Unexpected wrapper element XYZ found. Expected" | |
// One could argue, that this is syntactically incorrect, but here we just take it as Non-Scheme-compliant | |
|| isNotNull(faultMessage) && faultMessage.contains("Unexpected wrapper element")) { | |
return true; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static Document marhallJaxbElement(Object jaxbElement) throws BusinessException { | |
Document jaxbDoc = null; | |
try { | |
Marshaller marshaller = setUpMarshaller(jaxbElement.getClass()); | |
jaxbDoc = createNewDocument(); | |
marshaller.marshal(jaxbElement, jaxbDoc); | |
} catch (Exception exception) { | |
throw new BusinessException("Problem beim marshallen des JAXBElements in ein Document: " + exception.getMessage()); | |
} | |
return jaxbDoc; |