Migrated Stock Quote sample to maven

This commit is contained in:
Arjen Poutsma
2010-02-26 11:13:33 +00:00
parent d9b6e9891f
commit 331e7eba35
24 changed files with 203 additions and 421 deletions

View File

@@ -0,0 +1,63 @@
<?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/maven-v4_0_0.xsd">
<parent>
<artifactId>stockquote-client</artifactId>
<groupId>org.springframework.ws</groupId>
<version>2.0.0-M1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>stockquote-jax-ws-client</artifactId>
<packaging>jar</packaging>
<name>Spring WS Stock Quote Sample - JAX-WS Client</name>
<profiles>
<profile>
<id>jdk15</id>
<activation>
<jdk>!1.6</jdk>
</activation>
<dependencies>
<dependency>
<groupId>javax.xml.soap</groupId>
<artifactId>saaj-api</artifactId>
<scope>compile</scope>
</dependency>
</dependencies>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<wsdlUrls>
<wsdlUrl>file://${project.basedir}/../../server//src/main/resources/org/springframework/ws/samples/stockquote/ws/stockquote.wsdl</wsdlUrl>
</wsdlUrls>
<packageName>org.springframework.ws.samples.stockquote.client.jaxws</packageName>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>org.springframework.ws.samples.stockquote.client.jaxws.Main</mainClass>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@@ -1,11 +0,0 @@
SPRING WEB SERVICES
This directory contains a Java client for the Stock Quote Web Service that uses JAX-WS.
The client can be run from the provided ant file, by calling "ant run".
Note that the stock quote sample has to be running before invoking this target.
Client Sample table of contents
---------------------------------------------------
* src - The source files for the client
* build.xml - Ant build file with a 'build' and a 'run' target

View File

@@ -0,0 +1,17 @@
<?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/maven-v4_0_0.xsd">
<parent>
<artifactId>stockquote</artifactId>
<groupId>org.springframework.ws</groupId>
<version>2.0.0-M1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>stockquote-client</artifactId>
<packaging>pom</packaging>
<name>Spring WS Stock Quote Sample - Clients</name>
<modules>
<module>jax-ws</module>
<module>spring-ws</module>
</modules>
</project>

View File

@@ -0,0 +1,60 @@
<?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/maven-v4_0_0.xsd">
<parent>
<artifactId>stockquote-client</artifactId>
<groupId>org.springframework.ws</groupId>
<version>2.0.0-M1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>stockquote-spring-ws-client</artifactId>
<packaging>jar</packaging>
<name>Spring WS Stock Quote Sample - Spring-WS Client</name>
<profiles>
<profile>
<id>jdk15</id>
<activation>
<jdk>!1.6</jdk>
</activation>
<dependencies>
<dependency>
<groupId>javax.xml.soap</groupId>
<artifactId>saaj-api</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>org.springframework.ws.samples.stockquote.client.sws.StockClient</mainClass>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-xml</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-ws-core</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -46,7 +46,9 @@ public class StockClient extends WebServiceGatewaySupport {
Source requestSource = new ResourceSource(request);
StringResult result = new StringResult();
getWebServiceTemplate().sendSourceAndReceiveToResult(requestSource, new ActionCallback(action), result);
System.out.println();
System.out.println(result);
System.out.println();
}
public static void main(String[] args) throws IOException {

View File

@@ -1,16 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<customBinding>
<binding name="Soap11AddressingBinding" closeTimeout="00:01:00" sendTimeout="00:10:00">
<textMessageEncoding messageVersion="Soap11WSAddressing10"/>
<httpTransport/>
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="http://localhost:8080/StockService" binding="customBinding" bindingConfiguration="Soap11AddressingBinding" contract="Spring.Ws.Samples.Stock.Client.Wcf.Stock"/>
</client>
</system.serviceModel>
</configuration>

View File

@@ -1,5 +0,0 @@
@echo off
set WCF_PATH=%WINDIR%\Microsoft.NET\Framework\v3.0\Windows Communication Foundation
svcutil /noLogo /out:src\StockService.cs -namespace:http://www.springframework.org/spring-ws/samples/stockquote,Spring.Ws.Samples.Stock.Client.Wcf /noConfig http://localhost:8080/StockService.wsdl
csc /noLogo /out:bin\client.exe src\Main.cs src\StockService.cs
copy src\*.config bin\

View File

@@ -1,12 +0,0 @@
SPRING WEB SERVICES
This directory contains a C# client for the Stock Quote Web Service that uses
Windows Communication Foundation. The client can be built using the specific
build file, which requires WCF (.NET 3.0) on the patch. Note that the stock
quote sample has to be running before invoking this target.
Client Sample table of contents
---------------------------------------------------
* src - The source files for the client
* build.bat - Build bactch file

View File

@@ -1,59 +0,0 @@
using System;
using System.IO;
using System.ServiceModel;
namespace Spring.Ws.Samples.Stock.Client.Wcf
{
public class Client
{
public static void Main(string[] args)
{
StockClient wcfClient = new StockClient();
try
{
string[] symbols = new string[] { "FABRIKAM", "CONTOSO" };
StockQuoteRequest request = new StockQuoteRequest(symbols);
Console.Out.WriteLine("Requesting quotes for {0}", symbols);
StockQuote[] quotes = wcfClient.StockQuote(symbols);
Console.Out.WriteLine("Got {0} results", quotes.Length);
foreach (StockQuote quote in quotes)
{
Console.Out.WriteLine();
Console.Out.WriteLine("Symbol: " + quote.Symbol);
Console.Out.WriteLine("\tName:\t\t\t" + quote.Name);
Console.Out.WriteLine("\tLast Price:\t\t" + quote.Last);
Console.Out.WriteLine("\tPrevious Change:\t" + quote.Change + "%");
}
}
catch (TimeoutException ex)
{
Console.Error.WriteLine("The service operation timed out. " + ex.Message);
wcfClient.Abort();
}
catch (FaultException ex)
{
Console.Error.WriteLine("SOAP Fault Code {0}", ex.Code);
Console.Error.WriteLine("SOAP Fault Reason: {0}", ex.Reason);
wcfClient.Abort();
}
catch (CommunicationException ex)
{
Console.WriteLine(ex.GetType());
Console.Error.WriteLine("There was a communication problem. " + ex.Message);
Console.Error.WriteLine(ex.StackTrace);
wcfClient.Abort();
}
catch (Exception ex)
{
Console.Error.WriteLine("Unknown exception. " + ex.Message);
Console.Error.WriteLine(ex.StackTrace);
wcfClient.Abort();
}
}
}
}

View File

@@ -1,207 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.1433
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("svcutil", "3.0.4506.648")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://www.springframework.org/spring-ws/samples/stockquote")]
public partial class StockQuote
{
private string symbolField;
private double lastField;
private System.DateTime dateField;
private double changeField;
private string nameField;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Order=0)]
public string Symbol
{
get
{
return this.symbolField;
}
set
{
this.symbolField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Order=1)]
public double Last
{
get
{
return this.lastField;
}
set
{
this.lastField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Order=2)]
public System.DateTime Date
{
get
{
return this.dateField;
}
set
{
this.dateField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Order=3)]
public double Change
{
get
{
return this.changeField;
}
set
{
this.changeField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Order=4)]
public string Name
{
get
{
return this.nameField;
}
set
{
this.nameField = value;
}
}
}
namespace Spring.Ws.Samples.Stock.Client.Wcf
{
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
[System.ServiceModel.ServiceContractAttribute(Namespace="http://www.springframework.org/spring-ws/samples/stockquote", ConfigurationName="Spring.Ws.Samples.Stock.Client.Wcf.Stock")]
public interface Stock
{
// CODEGEN: Generating message contract since the operation StockQuote is neither RPC nor document wrapped.
[System.ServiceModel.OperationContractAttribute(Action="http://www.springframework.org/spring-ws/samples/stockquote/StockService/GetQuote" +
"", ReplyAction="http://www.springframework.org/spring-ws/samples/stockquote/StockService/GetQuote" +
"Response")]
[System.ServiceModel.XmlSerializerFormatAttribute()]
Spring.Ws.Samples.Stock.Client.Wcf.StockQuoteResponse StockQuote(Spring.Ws.Samples.Stock.Client.Wcf.StockQuoteRequest request);
}
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
[System.ServiceModel.MessageContractAttribute(IsWrapped=false)]
public partial class StockQuoteRequest
{
[System.ServiceModel.MessageBodyMemberAttribute(Name="StockQuoteRequest", Namespace="http://www.springframework.org/spring-ws/samples/stockquote", Order=0)]
[System.Xml.Serialization.XmlArrayItemAttribute("Symbol", IsNullable=false)]
public string[] StockQuoteRequest1;
public StockQuoteRequest()
{
}
public StockQuoteRequest(string[] StockQuoteRequest1)
{
this.StockQuoteRequest1 = StockQuoteRequest1;
}
}
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
[System.ServiceModel.MessageContractAttribute(IsWrapped=false)]
public partial class StockQuoteResponse
{
[System.ServiceModel.MessageBodyMemberAttribute(Name="StockQuoteResponse", Namespace="http://www.springframework.org/spring-ws/samples/stockquote", Order=0)]
[System.Xml.Serialization.XmlArrayItemAttribute(IsNullable=false)]
public StockQuote[] StockQuoteResponse1;
public StockQuoteResponse()
{
}
public StockQuoteResponse(StockQuote[] StockQuoteResponse1)
{
this.StockQuoteResponse1 = StockQuoteResponse1;
}
}
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
public interface StockChannel : Spring.Ws.Samples.Stock.Client.Wcf.Stock, System.ServiceModel.IClientChannel
{
}
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
public partial class StockClient : System.ServiceModel.ClientBase<Spring.Ws.Samples.Stock.Client.Wcf.Stock>, Spring.Ws.Samples.Stock.Client.Wcf.Stock
{
public StockClient()
{
}
public StockClient(string endpointConfigurationName) :
base(endpointConfigurationName)
{
}
public StockClient(string endpointConfigurationName, string remoteAddress) :
base(endpointConfigurationName, remoteAddress)
{
}
public StockClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) :
base(endpointConfigurationName, remoteAddress)
{
}
public StockClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) :
base(binding, remoteAddress)
{
}
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
Spring.Ws.Samples.Stock.Client.Wcf.StockQuoteResponse Spring.Ws.Samples.Stock.Client.Wcf.Stock.StockQuote(Spring.Ws.Samples.Stock.Client.Wcf.StockQuoteRequest request)
{
return base.Channel.StockQuote(request);
}
public StockQuote[] StockQuote(string[] StockQuoteRequest1)
{
Spring.Ws.Samples.Stock.Client.Wcf.StockQuoteRequest inValue = new Spring.Ws.Samples.Stock.Client.Wcf.StockQuoteRequest();
inValue.StockQuoteRequest1 = StockQuoteRequest1;
Spring.Ws.Samples.Stock.Client.Wcf.StockQuoteResponse retVal = ((Spring.Ws.Samples.Stock.Client.Wcf.Stock)(this)).StockQuote(inValue);
return retVal.StockQuoteResponse1;
}
}
}

View File

@@ -1,16 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<customBinding>
<binding name="Soap11AddressingBinding" closeTimeout="00:01:00" sendTimeout="00:10:00">
<textMessageEncoding messageVersion="Soap11WSAddressing10"/>
<httpTransport/>
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="http://localhost:8080/StockService" binding="customBinding" bindingConfiguration="Soap11AddressingBinding" contract="Spring.Ws.Samples.Stock.Client.Wcf.Stock"/>
</client>
</system.serviceModel>
</configuration>

View File

@@ -1,95 +0,0 @@
<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/maven-v4_0_0.xsd">
<parent>
<artifactId>spring-ws-samples</artifactId>
<groupId>org.springframework.ws</groupId>
<version>2.0.0-M1-SNAPSHOT</version>
<relativePath>../samples/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>stockquote</artifactId>
<packaging>jar</packaging>
<name>Spring WS Stock Quote Sample</name>
<description>A Spring-WS sample that shows usage of WS-Addressing and the HTTP Server built into JDK 1.6.</description>
<reporting>
<plugins>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<stylesheetfile>${basedir}/../../src/main/javadoc/javadoc.css</stylesheetfile>
</configuration>
</plugin>
</plugins>
</reporting>
<pluginRepositories>
<pluginRepository>
<id>java.net</id>
<name>Java.net Repository for Maven2</name>
<url>http://download.java.net/maven/1/</url>
<layout>legacy</layout>
</pluginRepository>
</pluginRepositories>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>com.sun.tools.xjc.maven2</groupId>
<artifactId>maven-jaxb-plugin</artifactId>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<generatePackage>org.springframework.ws.samples.stockquote.schema</generatePackage>
<includeSchemas>
<includeSchema>stockquote.wsdl</includeSchema>
</includeSchemas>
<schemaDirectory>src/main/resources/org/springframework/ws/samples/stockquote/ws</schemaDirectory>
<args>-wsdl</args>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>org.springframework.ws.samples.stockquote.Driver</mainClass>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- Spring-WS dependencies -->
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-ws-core-tiger</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-ws-support</artifactId>
</dependency>
<!-- Test dependencies -->
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<scope>test</scope>
<version>2.2</version>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,61 @@
<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/maven-v4_0_0.xsd">
<parent>
<artifactId>stockquote</artifactId>
<groupId>org.springframework.ws</groupId>
<version>2.0.0-M1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>stockquote-server</artifactId>
<packaging>jar</packaging>
<name>Spring WS Stock Quote Sample - Server</name>
<description>A Spring-WS sample that shows usage of WS-Addressing and the HTTP Server built into JDK 1.6.</description>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<schemaDirectory>src/main/resources/org/springframework/ws/samples/stockquote/ws</schemaDirectory>
<schemaFiles>stockquote.wsdl</schemaFiles>
<packageName>org.springframework.ws.samples.stockquote.schema</packageName>
<wsdl>true</wsdl>
<xmlschema>false</xmlschema>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>org.springframework.ws.samples.stockquote.Driver</mainClass>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- Spring-WS dependencies -->
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-ws-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-ws-support</artifactId>
</dependency>
</dependencies>
</project>