Skip to content

Commit

Permalink
Split up into server and client
Browse files Browse the repository at this point in the history
  • Loading branch information
gregturn committed Jul 15, 2014
1 parent 9225fde commit 3af8c18
Show file tree
Hide file tree
Showing 20 changed files with 480 additions and 77 deletions.
64 changes: 64 additions & 0 deletions learning-spring-ws-client/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.greglturnquist</groupId>
<artifactId>learning-spring-ws-client</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Learning Spring WS - Client</name>
<description>Learning Spring WS</description>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.1.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-ws</artifactId>
</dependency>
</dependencies>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<start-class>com.greglturnquist.learningspringws.Client</start-class>
<java.version>1.7</java.version>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<schemaLanguage>WSDL</schemaLanguage>
<generatePackage>com.greglturnquist.wsdl</generatePackage>
<forceRegenerate>true</forceRegenerate>
<schemas>
<schema>
<url>http://localhost:8080/ws/network-events.wsdl</url>
</schema>
</schemas>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.greglturnquist.learningspringws;

import com.greglturnquist.wsdl.SendNetworkEventResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.context.ApplicationContext;

public class Client {

private static final Logger log = LoggerFactory.getLogger(Client.class);

public static void main(String[] args) {
ApplicationContext ctx = SpringApplication.run(NetworkEventConfiguration.class, args);

NetworkEventClient networkEventClient = ctx.getBean(NetworkEventClient.class);
SendNetworkEventResponse response = networkEventClient.sendNetworkEvent();
log.info(response.toString());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.greglturnquist.learningspringws;

import java.math.BigInteger;

import com.greglturnquist.wsdl.SendNetworkEventRequest;
import com.greglturnquist.wsdl.SendNetworkEventResponse;
import org.springframework.ws.client.core.support.WebServiceGatewaySupport;
import org.springframework.ws.soap.client.core.SoapActionCallback;

public class NetworkEventClient extends WebServiceGatewaySupport {

public SendNetworkEventResponse sendNetworkEvent() {

SendNetworkEventRequest request = new SendNetworkEventRequest();
request.setHostname("retina");
request.setDescription("New event!");
request.setSeverity(BigInteger.valueOf(5));

return (SendNetworkEventResponse) getWebServiceTemplate().marshalSendAndReceive(
request,
new SoapActionCallback("http://localhost:8080/ws"));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.greglturnquist.learningspringws;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.oxm.jaxb.Jaxb2Marshaller;

@Configuration
public class NetworkEventConfiguration {

@Bean
Jaxb2Marshaller marshaller() {
Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
marshaller.setContextPath("com.greglturnquist.wsdl");
return marshaller;
}

@Bean
NetworkEventClient client(Jaxb2Marshaller marshaller) {
NetworkEventClient networkEventClient = new NetworkEventClient();
networkEventClient.setDefaultUri("http://localhost:8080/ws");
networkEventClient.setMarshaller(marshaller);
networkEventClient.setUnmarshaller(marshaller);
return networkEventClient;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
server.port=9000
File renamed without changes.
70 changes: 70 additions & 0 deletions learning-spring-ws-server/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.greglturnquist</groupId>
<artifactId>learning-spring-ws-server</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Learning Spring WS - Server</name>
<description>Learning Spring WS</description>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.1.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-ws</artifactId>
</dependency>
<dependency>
<groupId>wsdl4j</groupId>
<artifactId>wsdl4j</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<start-class>com.greglturnquist.learningspringws.Server</start-class>
<java.version>1.7</java.version>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>xjc</id>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<schemaDirectory>${project.basedir}/src/main/resources/</schemaDirectory>
<outputDirectory>${project.basedir}/src/main/java</outputDirectory>
<clearOutputDir>false</clearOutputDir>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ServletRegistrationBean dispatcherServlet(ApplicationContext ctx) {
return new ServletRegistrationBean(servlet, "/ws/*");
}

@Bean
@Bean(name = "network-events")
DefaultWsdl11Definition defaultWsdl11Definition(XsdSchema networkEventSchema) {

DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.7
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2014.07.14 at 09:51:20 PM CDT
//


package com.greglturnquist.test;

import javax.xml.bind.annotation.XmlRegistry;


/**
* This object contains factory methods for each
* Java content interface and Java element interface
* generated in the com.greglturnquist.test package.
* <p>An ObjectFactory allows you to programatically
* construct new instances of the Java representation
* for XML content. The Java representation of XML
* content can consist of schema derived interfaces
* and classes representing the binding of schema
* type definitions, element declarations and model
* groups. Factory methods for each of these are
* provided in this class.
*
*/
@XmlRegistry
public class ObjectFactory {


/**
* Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.greglturnquist.test
*
*/
public ObjectFactory() {
}

/**
* Create an instance of {@link SendNetworkEventRequest }
*
*/
public SendNetworkEventRequest createSendNetworkEventRequest() {
return new SendNetworkEventRequest();
}

/**
* Create an instance of {@link SendNetworkEventResponse }
*
*/
public SendNetworkEventResponse createSendNetworkEventResponse() {
return new SendNetworkEventResponse();
}

}
Loading

0 comments on commit 3af8c18

Please sign in to comment.