Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Specify what files to send on the client + increase maximum request l…

…ength to 300MB
  • Loading branch information...
commit 08257893dfc15ea3873939583f6ff8fb44b28bdd 1 parent c7fe77e
Milan Gardian milang authored
27 Source/SampleWcf.TestClient/Program.cs
View
@@ -1,4 +1,7 @@
using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
using System.ServiceModel.Web;
using SampleWcf.TestClient.SampleWcfCall;
@@ -17,22 +20,30 @@ public static void Main(string[] args)
{
try
{
- Console.WriteLine("Start sending");
- using (var f = new WebChannelFactory<IFileTracker>(new Uri("http://mgardian/samplewcf/Call.svc/FileTracker")))
+ Console.WriteLine("Gathering files");
+ var files = new List<FileDescriptor>();
+ if (args != null)
+ {
+ files.AddRange(
+ args
+ .Where(File.Exists)
+ .Select(a => new FileDescriptor { Name = a, Contents = File.ReadAllBytes(a) }));
+ }
+
+ Console.WriteLine("Send files");
+ using (var f = new WebChannelFactory<IFileTracker>(new Uri("http://localhost/samplewcf/Call.svc/FileTracker")))
{
var c = f.CreateChannel();
- c.Track(new[]
- {
- "First.txt",
- "Second.txt"
- });
+ c.Track(files.ToArray());
}
- Console.WriteLine("Done sending");
+ Console.WriteLine("Done");
}
catch (Exception ex)
{
+ Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(ex.Message);
Console.WriteLine(ex.StackTrace);
+ Console.ResetColor();
}
}
2  Source/SampleWcf.TestClient/Service References/SampleWcfCall/Call.wsdl
View
@@ -4,7 +4,7 @@
<xsd:schema targetNamespace="http://tempuri.org/Imports">
<xsd:import schemaLocation="http://localhost/samplewcf/Call.svc?xsd=xsd0" namespace="http://tempuri.org/" />
<xsd:import schemaLocation="http://localhost/samplewcf/Call.svc?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/" />
- <xsd:import schemaLocation="http://localhost/samplewcf/Call.svc?xsd=xsd2" namespace="http://schemas.microsoft.com/2003/10/Serialization/Arrays" />
+ <xsd:import schemaLocation="http://localhost/samplewcf/Call.svc?xsd=xsd2" namespace="http://schemas.datacontract.org/2004/07/SampleWcf.Web" />
</xsd:schema>
</wsdl:types>
<wsdl:message name="IFileTracker_Track_InputMessage">
4 Source/SampleWcf.TestClient/Service References/SampleWcfCall/Call1.xsd
View
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:tns="http://tempuri.org/" elementFormDefault="qualified" targetNamespace="http://tempuri.org/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
- <xs:import schemaLocation="http://localhost/samplewcf/Call.svc?xsd=xsd2" namespace="http://schemas.microsoft.com/2003/10/Serialization/Arrays" />
+ <xs:import schemaLocation="http://localhost/samplewcf/Call.svc?xsd=xsd2" namespace="http://schemas.datacontract.org/2004/07/SampleWcf.Web" />
<xs:element name="Track">
<xs:complexType>
<xs:sequence>
- <xs:element xmlns:q1="http://schemas.microsoft.com/2003/10/Serialization/Arrays" minOccurs="0" name="files" nillable="true" type="q1:ArrayOfstring" />
+ <xs:element xmlns:q1="http://schemas.datacontract.org/2004/07/SampleWcf.Web" minOccurs="0" name="files" nillable="true" type="q1:ArrayOfFileDescriptor" />
</xs:sequence>
</xs:complexType>
</xs:element>
21 Source/SampleWcf.TestClient/Service References/SampleWcfCall/Call2.xsd
View
@@ -1,9 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
-<xs:schema xmlns:tns="http://schemas.microsoft.com/2003/10/Serialization/Arrays" elementFormDefault="qualified" targetNamespace="http://schemas.microsoft.com/2003/10/Serialization/Arrays" xmlns:xs="http://www.w3.org/2001/XMLSchema">
- <xs:complexType name="ArrayOfstring">
+<xs:schema xmlns:tns="http://schemas.datacontract.org/2004/07/SampleWcf.Web" elementFormDefault="qualified" targetNamespace="http://schemas.datacontract.org/2004/07/SampleWcf.Web" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:import schemaLocation="http://localhost/samplewcf/Call.svc?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/" />
+ <xs:complexType name="ArrayOfFileDescriptor">
<xs:sequence>
- <xs:element minOccurs="0" maxOccurs="unbounded" name="string" nillable="true" type="xs:string" />
+ <xs:element minOccurs="0" maxOccurs="unbounded" name="FileDescriptor" type="tns:FileDescriptor" />
</xs:sequence>
</xs:complexType>
- <xs:element name="ArrayOfstring" nillable="true" type="tns:ArrayOfstring" />
+ <xs:element name="ArrayOfFileDescriptor" nillable="true" type="tns:ArrayOfFileDescriptor" />
+ <xs:complexType name="FileDescriptor">
+ <xs:annotation>
+ <xs:appinfo>
+ <IsValueType xmlns="http://schemas.microsoft.com/2003/10/Serialization/">true</IsValueType>
+ </xs:appinfo>
+ </xs:annotation>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="Contents" nillable="true" type="xs:base64Binary" />
+ <xs:element minOccurs="0" name="Name" nillable="true" type="xs:string" />
+ </xs:sequence>
+ </xs:complexType>
+ <xs:element name="FileDescriptor" nillable="true" type="tns:FileDescriptor" />
</xs:schema>
66 Source/SampleWcf.TestClient/Service References/SampleWcfCall/Reference.cs
View
@@ -9,14 +9,76 @@
//------------------------------------------------------------------------------
namespace SampleWcf.TestClient.SampleWcfCall {
+ using System.Runtime.Serialization;
+ using System;
+ [System.Diagnostics.DebuggerStepThroughAttribute()]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
+ [System.Runtime.Serialization.DataContractAttribute(Name="FileDescriptor", Namespace="http://schemas.datacontract.org/2004/07/SampleWcf.Web")]
+ [System.SerializableAttribute()]
+ public partial struct FileDescriptor : System.Runtime.Serialization.IExtensibleDataObject, System.ComponentModel.INotifyPropertyChanged {
+
+ [System.NonSerializedAttribute()]
+ private System.Runtime.Serialization.ExtensionDataObject extensionDataField;
+
+ [System.Runtime.Serialization.OptionalFieldAttribute()]
+ private byte[] ContentsField;
+
+ [System.Runtime.Serialization.OptionalFieldAttribute()]
+ private string NameField;
+
+ public System.Runtime.Serialization.ExtensionDataObject ExtensionData {
+ get {
+ return this.extensionDataField;
+ }
+ set {
+ this.extensionDataField = value;
+ }
+ }
+
+ [System.Runtime.Serialization.DataMemberAttribute()]
+ public byte[] Contents {
+ get {
+ return this.ContentsField;
+ }
+ set {
+ if ((object.ReferenceEquals(this.ContentsField, value) != true)) {
+ this.ContentsField = value;
+ this.RaisePropertyChanged("Contents");
+ }
+ }
+ }
+
+ [System.Runtime.Serialization.DataMemberAttribute()]
+ public string Name {
+ get {
+ return this.NameField;
+ }
+ set {
+ if ((object.ReferenceEquals(this.NameField, value) != true)) {
+ this.NameField = value;
+ this.RaisePropertyChanged("Name");
+ }
+ }
+ }
+
+ public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
+
+ void RaisePropertyChanged(string propertyName) {
+ System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
+ if ((propertyChanged != null)) {
+ propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
+ }
+ }
+ }
+
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ServiceModel.ServiceContractAttribute(ConfigurationName="SampleWcfCall.IFileTracker")]
public interface IFileTracker {
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IFileTracker/Track", ReplyAction="http://tempuri.org/IFileTracker/TrackResponse")]
- void Track(string[] files);
+ void Track(SampleWcf.TestClient.SampleWcfCall.FileDescriptor[] files);
}
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
@@ -46,7 +108,7 @@ public partial class FileTrackerClient : System.ServiceModel.ClientBase<SampleWc
base(binding, remoteAddress) {
}
- public void Track(string[] files) {
+ public void Track(SampleWcf.TestClient.SampleWcfCall.FileDescriptor[] files) {
base.Channel.Track(files);
}
}
4 Source/SampleWcf.Web/Call.svc.cs
View
@@ -19,14 +19,14 @@ public class Call : IFileTracker
//--------------------------------------------------
/// <summary>
/// </summary>
- public void Track(IEnumerable<string> files)
+ public void Track(IEnumerable<FileDescriptor> files)
{
Debugger.Log(0, null, string.Concat("--- Received files:", Environment.NewLine));
if (files != null)
{
foreach (var file in files)
{
- Debugger.Log(0, null, string.Concat("File: \"", file, "\"", Environment.NewLine));
+ Debugger.Log(0, null, string.Concat("File: \"", file.Name, "\" has length ", file.Contents == null ? 0 : file.Contents.Length, Environment.NewLine));
}
}
Debugger.Log(0, null, string.Concat("--- Received files end", Environment.NewLine));
16 Source/SampleWcf.Web/FileDescriptor.cs
View
@@ -0,0 +1,16 @@
+using System.Runtime.Serialization;
+
+namespace SampleWcf.Web
+{
+
+ [DataContract]
+ public struct FileDescriptor
+ {
+ [DataMember]
+ public string Name { get; set; }
+
+ [DataMember]
+ public byte[] Contents { get; set; }
+ }
+
+}
2  Source/SampleWcf.Web/FileTracker.cs
View
@@ -10,7 +10,7 @@ public interface IFileTracker
{
[OperationContract, WebInvoke(Method = "POST")]
- void Track(IEnumerable<string> files);
+ void Track(IEnumerable<FileDescriptor> files);
}
1  Source/SampleWcf.Web/SampleWcf.Web.csproj
View
@@ -60,6 +60,7 @@
<Compile Include="Call.svc.cs">
<DependentUpon>Call.svc</DependentUpon>
</Compile>
+ <Compile Include="FileDescriptor.cs" />
<Compile Include="Global.asax.cs">
<DependentUpon>Global.asax</DependentUpon>
</Compile>
16 Source/SampleWcf.Web/Web.config
View
@@ -8,6 +8,7 @@
<system.web>
<compilation debug="false" targetFramework="4.0" />
+ <httpRuntime maxRequestLength="300000000" executionTimeout="180" />
<!--
<authentication mode="Forms">
@@ -41,8 +42,21 @@
<system.webServer>
<validation validateIntegratedModeConfiguration="true"/>
<modules runAllManagedModulesForAllRequests="true"/>
+ <security>
+ <requestFiltering>
+ <requestLimits maxAllowedContentLength="300000000" />
+ </requestFiltering>
+ </security>
</system.webServer>
<system.serviceModel>
+ <bindings>
+ <webHttpBinding>
+ <binding name="SampleWcfServiceBinding" maxReceivedMessageSize="300000000" maxBufferPoolSize="300000000" maxBufferSize="300000000" closeTimeout="00:03:00" openTimeout="00:03:00" receiveTimeout="00:10:00" sendTimeout="00:03:00">
+ <readerQuotas maxStringContentLength="300000000" maxArrayLength="300000000" maxBytesPerRead="300000000" />
+ <security mode="None"/>
+ </binding>
+ </webHttpBinding>
+ </bindings>
<behaviors>
<serviceBehaviors>
<behavior name="SampleWcfServiceBehaviour">
@@ -59,7 +73,7 @@
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<services>
<service name="SampleWcf.Web.Call" behaviorConfiguration="SampleWcfServiceBehaviour">
- <endpoint address="FileTracker" behaviorConfiguration="SampleWcfEndpointWebBehavior" binding="webHttpBinding" contract="SampleWcf.Web.IFileTracker" />
+ <endpoint address="FileTracker" behaviorConfiguration="SampleWcfEndpointWebBehavior" binding="webHttpBinding" bindingConfiguration="SampleWcfServiceBinding" contract="SampleWcf.Web.IFileTracker" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
Please sign in to comment.
Something went wrong with that request. Please try again.