Reworked mtom sample to code config
This commit is contained in:
@@ -2,12 +2,10 @@ configurations {
|
||||
jaxb
|
||||
}
|
||||
|
||||
ext.springWsVersion = '2.1.4.RELEASE'
|
||||
|
||||
task genJaxb {
|
||||
ext.sourcesDir = "${buildDir}/generated-sources/jaxb"
|
||||
ext.classesDir = "${buildDir}/classes/jaxb"
|
||||
ext.schema = "${projectDir}/../../server/src/main/webapp/WEB-INF/schema.xsd"
|
||||
ext.schema = "${projectDir}/../../server/src/main/resources/schema.xsd"
|
||||
|
||||
inputs.files schema
|
||||
outputs.dir classesDir
|
||||
@@ -43,6 +41,7 @@ task genJaxb {
|
||||
|
||||
dependencies {
|
||||
compile("org.springframework.ws:spring-ws-core:$springWsVersion")
|
||||
compile("org.springframework:spring-context:$springVersion")
|
||||
compile("org.apache.ws.commons.axiom:axiom-api:1.2.14")
|
||||
compile(files(genJaxb.classesDir).builtBy(genJaxb))
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package org.springframework.ws.samples.mtom.client.sws;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
|
||||
public class Driver {
|
||||
|
||||
@@ -27,7 +27,7 @@ public class Driver {
|
||||
fileName = args[0];
|
||||
}
|
||||
ApplicationContext applicationContext =
|
||||
new ClassPathXmlApplicationContext("applicationContext.xml", Driver.class);
|
||||
new AnnotationConfigApplicationContext(MtomClientConfig.class);
|
||||
|
||||
SaajMtomClient saajClient = applicationContext.getBean("saajClient", SaajMtomClient.class);
|
||||
saajClient.doIt(fileName);
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package org.springframework.ws.samples.mtom.client.sws;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.oxm.jaxb.Jaxb2Marshaller;
|
||||
import org.springframework.ws.soap.axiom.AxiomSoapMessageFactory;
|
||||
import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;
|
||||
|
||||
/**
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
@Configuration
|
||||
public class MtomClientConfig {
|
||||
|
||||
@Bean
|
||||
public SaajMtomClient saajClient() {
|
||||
SaajMtomClient client = new SaajMtomClient(saajSoapMessageFactory());
|
||||
client.setDefaultUri("http://localhost:8080/mtom-server/services");
|
||||
client.setMarshaller(marshaller());
|
||||
client.setUnmarshaller(marshaller());
|
||||
return client;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public SaajSoapMessageFactory saajSoapMessageFactory() {
|
||||
return new SaajSoapMessageFactory();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public AxiomMtomClient axiomClient() {
|
||||
AxiomMtomClient client = new AxiomMtomClient(axiomSoapMessageFactory());
|
||||
client.setDefaultUri("http://localhost:8080/mtom-server/services");
|
||||
return client;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public AxiomSoapMessageFactory axiomSoapMessageFactory() {
|
||||
return new AxiomSoapMessageFactory();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Jaxb2Marshaller marshaller() {
|
||||
Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
|
||||
marshaller.setContextPath("org.springframework.ws.samples.mtom.client.sws");
|
||||
marshaller.setMtomEnabled(true);
|
||||
return marshaller;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -27,7 +27,7 @@ import org.springframework.ws.soap.client.SoapFaultClientException;
|
||||
import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;
|
||||
|
||||
/**
|
||||
* Simple client that demonstartes MTOM by invoking <code>StoreImage</code> and <code>LoadImage</code> using a
|
||||
* Simple client that demonstrates MTOM by invoking {@code StoreImage} and {@code LoadImage} using a
|
||||
* WebServiceTemplate and SAAJ.
|
||||
*
|
||||
* @author Tareq Abed Rabbo
|
||||
@@ -66,6 +66,7 @@ public class SaajMtomClient extends WebServiceGatewaySupport {
|
||||
stopWatch.stop();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void load(String path) {
|
||||
JAXBElement<String> loadImageRequest = objectFactory.createLoadImageRequest(StringUtils.getFilename(path));
|
||||
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
|
||||
|
||||
<bean id="client" abstract="true">
|
||||
<property name="defaultUri" value="http://localhost:8080/mtom-server/services"/>
|
||||
</bean>
|
||||
|
||||
<bean id="saajClient" class="org.springframework.ws.samples.mtom.client.sws.SaajMtomClient" parent="client">
|
||||
<constructor-arg>
|
||||
<bean class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory"/>
|
||||
</constructor-arg>
|
||||
<property name="marshaller" ref="marshaller"/>
|
||||
<property name="unmarshaller" ref="marshaller"/>
|
||||
</bean>
|
||||
|
||||
<bean id="marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
|
||||
<property name="contextPath" value="org.springframework.ws.samples.mtom.client.sws"/>
|
||||
<property name="mtomEnabled" value="true"/>
|
||||
</bean>
|
||||
|
||||
<bean id="axiomClient" class="org.springframework.ws.samples.mtom.client.sws.AxiomMtomClient" parent="client">
|
||||
<constructor-arg>
|
||||
<bean class="org.springframework.ws.soap.axiom.AxiomSoapMessageFactory"/>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
Reference in New Issue
Block a user