diff --git a/samples/mtom/client/jaxws/build.xml b/samples/mtom/client/jaxws/build.xml index 6187e150..2197535b 100644 --- a/samples/mtom/client/jaxws/build.xml +++ b/samples/mtom/client/jaxws/build.xml @@ -72,7 +72,7 @@ - + diff --git a/samples/mtom/client/jaxws/spring-ws-logo.png b/samples/mtom/client/spring-ws-logo.png similarity index 100% rename from samples/mtom/client/jaxws/spring-ws-logo.png rename to samples/mtom/client/spring-ws-logo.png diff --git a/samples/mtom/client/wcf/bin/image.exe b/samples/mtom/client/wcf/bin/image.exe new file mode 100644 index 00000000..a8d0fab8 Binary files /dev/null and b/samples/mtom/client/wcf/bin/image.exe differ diff --git a/samples/mtom/client/wcf/bin/image.exe.config b/samples/mtom/client/wcf/bin/image.exe.config new file mode 100644 index 00000000..bc2a9bec --- /dev/null +++ b/samples/mtom/client/wcf/bin/image.exe.config @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/samples/mtom/client/wcf/build.bat b/samples/mtom/client/wcf/build.bat new file mode 100644 index 00000000..ed32706b --- /dev/null +++ b/samples/mtom/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\ImageRepositoryService.cs -namespace:http://www.springframework.org/spring-ws/samples/mtom,Spring.Ws.Samples.Mtom.Client.Wcf /noConfig http://localhost:8080/mtom/mtom.wsdl +csc /noLogo /out:bin\image.exe /reference:%WCF_PATH%\System.ServiceModel.dll src\Main.cs src\ImageRepositoryService.cs +copy src\*.config bin\ \ No newline at end of file diff --git a/samples/mtom/client/wcf/readme.txt b/samples/mtom/client/wcf/readme.txt new file mode 100644 index 00000000..25dd4a2d --- /dev/null +++ b/samples/mtom/client/wcf/readme.txt @@ -0,0 +1,13 @@ +SPRING WEB SERVICES + +This directory contains a .NET 3.0 client for the MTOM Sample that uses +Windows Communication Foundation (WCF). The client can be run with the +given run.bat batch file, or rebuilt by calling build.bat. + +Client Sample table of contents +--------------------------------------------------- +* bin - The executable files for the client: image.exe +* src - The source files for the client +* build.bat - .NET build batch file +* run.bat - runs image.exe + diff --git a/samples/mtom/client/wcf/run.bat b/samples/mtom/client/wcf/run.bat new file mode 100644 index 00000000..e1463098 --- /dev/null +++ b/samples/mtom/client/wcf/run.bat @@ -0,0 +1,2 @@ +@echo off +bin\image ..\spring-ws-logo.png diff --git a/samples/mtom/client/wcf/spring-ws-logo.png b/samples/mtom/client/wcf/spring-ws-logo.png new file mode 100644 index 00000000..2bdbd1a6 Binary files /dev/null and b/samples/mtom/client/wcf/spring-ws-logo.png differ diff --git a/samples/mtom/client/wcf/src/ImageRepositoryService.cs b/samples/mtom/client/wcf/src/ImageRepositoryService.cs new file mode 100644 index 00000000..93d00928 --- /dev/null +++ b/samples/mtom/client/wcf/src/ImageRepositoryService.cs @@ -0,0 +1,190 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.42 +// +// 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.30")] +[System.SerializableAttribute()] +[System.Diagnostics.DebuggerStepThroughAttribute()] +[System.ComponentModel.DesignerCategoryAttribute("code")] +[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://www.springframework.org/spring-ws/samples/mtom")] +public partial class Image +{ + + private string nameField; + + private byte[] imageField; + + /// + [System.Xml.Serialization.XmlElementAttribute(Order=0)] + public string name + { + get + { + return this.nameField; + } + set + { + this.nameField = value; + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(DataType="base64Binary", Order=1)] + public byte[] image + { + get + { + return this.imageField; + } + set + { + this.imageField = value; + } + } +} +namespace Spring.Ws.Samples.Mtom.Client.Wcf +{ + + + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")] + [System.ServiceModel.ServiceContractAttribute(Namespace="http://www.springframework.org/spring-ws/samples/mtom", ConfigurationName="Spring.Ws.Samples.Mtom.Client.Wcf.ImageRepository")] + public interface ImageRepository + { + + // CODEGEN: Generating message contract since the operation StoreImage is neither RPC nor document wrapped. + [System.ServiceModel.OperationContractAttribute(IsOneWay=true, Action="")] + [System.ServiceModel.XmlSerializerFormatAttribute()] + void StoreImage(Spring.Ws.Samples.Mtom.Client.Wcf.StoreImageRequest request); + + // CODEGEN: Generating message contract since the operation LoadImage is neither RPC nor document wrapped. + [System.ServiceModel.OperationContractAttribute(Action="", ReplyAction="*")] + [System.ServiceModel.XmlSerializerFormatAttribute()] + Spring.Ws.Samples.Mtom.Client.Wcf.LoadImageResponse LoadImage(Spring.Ws.Samples.Mtom.Client.Wcf.LoadImageRequest request); + } + + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")] + [System.ServiceModel.MessageContractAttribute(IsWrapped=false)] + public partial class StoreImageRequest + { + + [System.ServiceModel.MessageBodyMemberAttribute(Name="StoreImageRequest", Namespace="http://www.springframework.org/spring-ws/samples/mtom", Order=0)] + public Image StoreImageRequest1; + + public StoreImageRequest() + { + } + + public StoreImageRequest(Image StoreImageRequest1) + { + this.StoreImageRequest1 = StoreImageRequest1; + } + } + + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")] + [System.ServiceModel.MessageContractAttribute(IsWrapped=false)] + public partial class LoadImageRequest + { + + [System.ServiceModel.MessageBodyMemberAttribute(Name="LoadImageRequest", Namespace="http://www.springframework.org/spring-ws/samples/mtom", Order=0)] + public string LoadImageRequest1; + + public LoadImageRequest() + { + } + + public LoadImageRequest(string LoadImageRequest1) + { + this.LoadImageRequest1 = LoadImageRequest1; + } + } + + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")] + [System.ServiceModel.MessageContractAttribute(IsWrapped=false)] + public partial class LoadImageResponse + { + + [System.ServiceModel.MessageBodyMemberAttribute(Name="LoadImageResponse", Namespace="http://www.springframework.org/spring-ws/samples/mtom", Order=0)] + public Image LoadImageResponse1; + + public LoadImageResponse() + { + } + + public LoadImageResponse(Image LoadImageResponse1) + { + this.LoadImageResponse1 = LoadImageResponse1; + } + } + + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")] + public interface ImageRepositoryChannel : Spring.Ws.Samples.Mtom.Client.Wcf.ImageRepository, System.ServiceModel.IClientChannel + { + } + + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")] + public partial class ImageRepositoryClient : System.ServiceModel.ClientBase, Spring.Ws.Samples.Mtom.Client.Wcf.ImageRepository + { + + public ImageRepositoryClient() + { + } + + public ImageRepositoryClient(string endpointConfigurationName) : + base(endpointConfigurationName) + { + } + + public ImageRepositoryClient(string endpointConfigurationName, string remoteAddress) : + base(endpointConfigurationName, remoteAddress) + { + } + + public ImageRepositoryClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : + base(endpointConfigurationName, remoteAddress) + { + } + + public ImageRepositoryClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : + base(binding, remoteAddress) + { + } + + void Spring.Ws.Samples.Mtom.Client.Wcf.ImageRepository.StoreImage(Spring.Ws.Samples.Mtom.Client.Wcf.StoreImageRequest request) + { + base.Channel.StoreImage(request); + } + + public void StoreImage(Image StoreImageRequest1) + { + Spring.Ws.Samples.Mtom.Client.Wcf.StoreImageRequest inValue = new Spring.Ws.Samples.Mtom.Client.Wcf.StoreImageRequest(); + inValue.StoreImageRequest1 = StoreImageRequest1; + ((Spring.Ws.Samples.Mtom.Client.Wcf.ImageRepository)(this)).StoreImage(inValue); + } + + Spring.Ws.Samples.Mtom.Client.Wcf.LoadImageResponse Spring.Ws.Samples.Mtom.Client.Wcf.ImageRepository.LoadImage(Spring.Ws.Samples.Mtom.Client.Wcf.LoadImageRequest request) + { + return base.Channel.LoadImage(request); + } + + public Image LoadImage(string LoadImageRequest1) + { + Spring.Ws.Samples.Mtom.Client.Wcf.LoadImageRequest inValue = new Spring.Ws.Samples.Mtom.Client.Wcf.LoadImageRequest(); + inValue.LoadImageRequest1 = LoadImageRequest1; + Spring.Ws.Samples.Mtom.Client.Wcf.LoadImageResponse retVal = ((Spring.Ws.Samples.Mtom.Client.Wcf.ImageRepository)(this)).LoadImage(inValue); + return retVal.LoadImageResponse1; + } + } +} diff --git a/samples/mtom/client/wcf/src/Main.cs b/samples/mtom/client/wcf/src/Main.cs new file mode 100644 index 00000000..7ec4a9ee --- /dev/null +++ b/samples/mtom/client/wcf/src/Main.cs @@ -0,0 +1,50 @@ +using System; +using System.IO; +using System.ServiceModel; + +namespace Spring.Ws.Samples.Mtom.Client.Wcf { + + public class Client { + public static void Main(string[] args) { + if (args.Length == 0) { + Console.Error.WriteLine("Usage: image.exe [filename]"); + return; + } + ImageRepositoryClient wcfClient = new ImageRepositoryClient(); + try { + Image image = new Image(); + FileInfo file = new FileInfo(args[0]); + image.name = file.Name; + byte[] buf = new byte[file.Length]; + using (FileStream stream = file.OpenRead()) + { + stream.Read(buf, 0, buf.Length); + } + image.image = buf; + DateTime start = DateTime.Now; + wcfClient.StoreImage(image); + TimeSpan interval = DateTime.Now - start; + Console.WriteLine("StoreImage took: {0,4:N0} ms.", interval.TotalMilliseconds); + + wcfClient.Close(); + + } 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/mtom/client/wcf/src/image.exe.config b/samples/mtom/client/wcf/src/image.exe.config new file mode 100644 index 00000000..bc2a9bec --- /dev/null +++ b/samples/mtom/client/wcf/src/image.exe.config @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + \ No newline at end of file