Added WCF client
This commit is contained in:
BIN
samples/stockquote/client/wcf/bin/client.exe
Normal file
BIN
samples/stockquote/client/wcf/bin/client.exe
Normal file
Binary file not shown.
16
samples/stockquote/client/wcf/bin/client.exe.config
Normal file
16
samples/stockquote/client/wcf/bin/client.exe.config
Normal file
@@ -0,0 +1,16 @@
|
||||
<?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>
|
||||
5
samples/stockquote/client/wcf/build.bat
Normal file
5
samples/stockquote/client/wcf/build.bat
Normal file
@@ -0,0 +1,5 @@
|
||||
@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\
|
||||
59
samples/stockquote/client/wcf/src/Main.cs
Normal file
59
samples/stockquote/client/wcf/src/Main.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
207
samples/stockquote/client/wcf/src/StockService.cs
Normal file
207
samples/stockquote/client/wcf/src/StockService.cs
Normal file
@@ -0,0 +1,207 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <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;
|
||||
}
|
||||
}
|
||||
}
|
||||
16
samples/stockquote/client/wcf/src/client.exe.config
Normal file
16
samples/stockquote/client/wcf/src/client.exe.config
Normal file
@@ -0,0 +1,16 @@
|
||||
<?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>
|
||||
Reference in New Issue
Block a user