Reworked echo sample to code config
Echo Sample now uses Javaconfig instead of XML.
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
ext.springWsVersion = '2.1.4.RELEASE'
|
||||
|
||||
dependencies {
|
||||
compile("org.springframework.ws:spring-ws-core:$springWsVersion")
|
||||
runtime("log4j:log4j:1.2.16")
|
||||
@@ -8,4 +6,4 @@ dependencies {
|
||||
task runClient(dependsOn: 'classes', type:JavaExec) {
|
||||
main = "org.springframework.ws.samples.echo.client.sws.EchoClient"
|
||||
classpath = sourceSets.main.runtimeClasspath
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import javax.xml.transform.Source;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.ws.client.core.support.WebServiceGatewaySupport;
|
||||
import org.springframework.xml.transform.ResourceSource;
|
||||
@@ -44,9 +45,11 @@ public class EchoClient extends WebServiceGatewaySupport {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
ApplicationContext applicationContext =
|
||||
new ClassPathXmlApplicationContext("applicationContext.xml", EchoClient.class);
|
||||
EchoClient echoClient = (EchoClient) applicationContext.getBean("echoClient");
|
||||
EchoClient echoClient = new EchoClient();
|
||||
echoClient.setDefaultUri("http://localhost:8080/echo-server/services");
|
||||
echoClient.setRequest(new ClassPathResource(
|
||||
"org/springframework/ws/samples/echo/client/sws/echoRequest.xml"));
|
||||
|
||||
echoClient.echo();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +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.xsd">
|
||||
|
||||
<bean id="echoClient" class="org.springframework.ws.samples.echo.client.sws.EchoClient">
|
||||
<property name="defaultUri" value="http://localhost:8080/echo-server/services"/>
|
||||
<property name="request" value="classpath:org/springframework/ws/samples/echo/client/sws/echoRequest.xml"/>
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
Reference in New Issue
Block a user