Added Windows Communication Foundation Client for MTOM sample.

This commit is contained in:
Arjen Poutsma
2007-06-06 21:24:01 +00:00
parent 1f5073786e
commit 34a07cd6b2
11 changed files with 297 additions and 1 deletions

View File

@@ -72,7 +72,7 @@
<target name="run" depends="build">
<java classname="org.springframework.ws.samples.mtom.client.jaxws.Main" fork="true" failonerror="true">
<arg path="spring-ws-logo.png"/>
<arg path="../spring-ws-logo.png"/>
<classpath refid="compile.classpath"/>
<classpath refid="runtime.classpath"/>
<classpath location="${bin.dir}"/>

View File

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<bindings>
<customBinding>
<binding name="SoapMtomBinding" closeTimeout="00:01:00" sendTimeout="00:10:00">
<mtomMessageEncoding messageVersion="Soap11" />
<httpTransport />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="http://localhost:8080/mtom/" binding="customBinding"
bindingConfiguration="SoapMtomBinding" contract="Spring.Ws.Samples.Mtom.Client.Wcf.ImageRepository"
name="ImageRepositoryPort" />
</client>
</system.serviceModel>
</configuration>

View File

@@ -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\

View File

@@ -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

View File

@@ -0,0 +1,2 @@
@echo off
bin\image ..\spring-ws-logo.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View File

@@ -0,0 +1,190 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 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.
// </auto-generated>
//------------------------------------------------------------------------------
/// <remarks/>
[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;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Order=0)]
public string name
{
get
{
return this.nameField;
}
set
{
this.nameField = value;
}
}
/// <remarks/>
[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>, 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;
}
}
}

View File

@@ -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();
}
}
}
}

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<bindings>
<customBinding>
<binding name="SoapMtomBinding" closeTimeout="00:01:00" sendTimeout="00:10:00">
<mtomMessageEncoding messageVersion="Soap11" />
<httpTransport />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="http://localhost:8080/mtom/" binding="customBinding"
bindingConfiguration="SoapMtomBinding" contract="Spring.Ws.Samples.Mtom.Client.Wcf.ImageRepository"
name="ImageRepositoryPort" />
</client>
</system.serviceModel>
</configuration>