From 7be90434e60ecf29ffb17427bf73fff5dd5cf1d5 Mon Sep 17 00:00:00 2001 From: Arjen Poutsma Date: Mon, 25 Feb 2008 13:26:28 +0000 Subject: [PATCH] Added WCF client --- samples/stockquote/client/wcf/bin/client.exe | Bin 0 -> 8704 bytes .../client/wcf/bin/client.exe.config | 16 ++ samples/stockquote/client/wcf/build.bat | 5 + samples/stockquote/client/wcf/src/Main.cs | 59 +++++ .../stockquote/client/wcf/src/StockService.cs | 207 ++++++++++++++++++ .../client/wcf/src/client.exe.config | 16 ++ 6 files changed, 303 insertions(+) create mode 100644 samples/stockquote/client/wcf/bin/client.exe create mode 100644 samples/stockquote/client/wcf/bin/client.exe.config create mode 100644 samples/stockquote/client/wcf/build.bat create mode 100644 samples/stockquote/client/wcf/src/Main.cs create mode 100644 samples/stockquote/client/wcf/src/StockService.cs create mode 100644 samples/stockquote/client/wcf/src/client.exe.config diff --git a/samples/stockquote/client/wcf/bin/client.exe b/samples/stockquote/client/wcf/bin/client.exe new file mode 100644 index 0000000000000000000000000000000000000000..767897240d5ee5c7a011d670fba2128f757039f0 GIT binary patch literal 8704 zcmeHMYmgjQbv`{kkDXcVSTif^71>={D=A*d*6c_tgCa}zJ|&OQW364SfP%7mXRbz# zdb&s5J^R2RS?t6?l;ikE912%RFb+lhgQ}G6;$;%sWKb&3k5qAI`}BF;bI!fz^u4!x55MOj(upXJ>(V8n&*RQ*OyI8us}N`3 z_Qfncm40E<=e0vGY??c5`9|GytDadi%BJJEfw7(C8cPtZ zm%sKsB108=0CtZuK1TEsPr~KxB+q!XNmVv9IjS)?Bkb*wT^NPl?#VA2@ zNX(vIA`LVy_Vzz&zg3J=7kr~{j(iwOW~lFvvtab5bLs0n@avz&|5!v|f+*uFI|4JAVle*mwRN@%AQY7=AO}zp$Bvi=<^b;!C4uElQkzK?sSD3@|E!iPnA?Yer`uB&w=+CE-EBxuM0HiIUrYn_~J0nc5EhNC#!XI#BJ< zVX8w1wa7Y9?a*PWLnpEW)eaq|I&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+ + + + + \ No newline at end of file diff --git a/samples/stockquote/client/wcf/build.bat b/samples/stockquote/client/wcf/build.bat new file mode 100644 index 00000000..5af9f17e --- /dev/null +++ b/samples/stockquote/client/wcf/build.bat @@ -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\ \ No newline at end of file diff --git a/samples/stockquote/client/wcf/src/Main.cs b/samples/stockquote/client/wcf/src/Main.cs new file mode 100644 index 00000000..8476d7db --- /dev/null +++ b/samples/stockquote/client/wcf/src/Main.cs @@ -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(); + } + } + } +} diff --git a/samples/stockquote/client/wcf/src/StockService.cs b/samples/stockquote/client/wcf/src/StockService.cs new file mode 100644 index 00000000..c95e4ade --- /dev/null +++ b/samples/stockquote/client/wcf/src/StockService.cs @@ -0,0 +1,207 @@ +//------------------------------------------------------------------------------ +// +// 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. +// +//------------------------------------------------------------------------------ + + + +/// +[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; + + /// + [System.Xml.Serialization.XmlElementAttribute(Order=0)] + public string Symbol + { + get + { + return this.symbolField; + } + set + { + this.symbolField = value; + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Order=1)] + public double Last + { + get + { + return this.lastField; + } + set + { + this.lastField = value; + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Order=2)] + public System.DateTime Date + { + get + { + return this.dateField; + } + set + { + this.dateField = value; + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(Order=3)] + public double Change + { + get + { + return this.changeField; + } + set + { + this.changeField = value; + } + } + + /// + [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 + { + + 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; + } + } +} diff --git a/samples/stockquote/client/wcf/src/client.exe.config b/samples/stockquote/client/wcf/src/client.exe.config new file mode 100644 index 00000000..75a57f8f --- /dev/null +++ b/samples/stockquote/client/wcf/src/client.exe.config @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file