dotnet web services enhancements:
I absolutely can not get the maxRequestLength property to work in a
TCP web services console application. Regardless of the setting, the
maximum file size that can be transfered is 4096kb, which is the
default setting. Might anyone be able to shed some light as to why my
development workstations won't change the default length.
I'm using XP Pro and VS2003 in Debug mode. IIS is currently turned
off.
Here's the SoapService code:
[SoapMethod(Literals.GetFileMethodProxy2)]
public SoapEnvelope GetFile2(string FileLocation)
{
try
{
Console.WriteLine("File has been requested: " + FileLocation);
SoapEnvelope soapenv = new SoapEnvelope();
Microsoft.Web.Services2.Dime.DimeAttachment att = new
Microsoft.Web.Services2.Dime.DimeAttachment("text/txt",
Microsoft.Web.Services2.Dime.TypeFormat.MediaType, FileLocation);
soapenv.Context.Attachments.Add(att);
return soapenv;
}
catch (Exception ex)
{
throw new SoapException(ex.Message,
SoapException.ClientFaultCode);
}
}
The Client code is as follows:
public void GetFileFromService2()
{
try
{
string file = @"c:\oldfiles.txt";
SoapEnvelope env =
base.SendRequestResponse(Literals.GetFileMethodProxy2, file);
Console.WriteLine(env.Context.Attachments.Count.ToString());
byte[] data = new byte[env.Context.Attachments[0].Stream.Length];
env.Context.Attachments[0].Stream.Read(data, 0, data.Length);
Console.WriteLine(System.Text.ASCIIEncoding.ASCII.GetString(data));
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
Console.ReadLine();
}
}
And lastly a look at the app.config file:
<configuration>
<configSections>
<section name="microsoft.web.services2"
type="Microsoft.Web.Services2.Configuration.WebServicesConfiguration,
Microsoft.Web.Services2, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35" />
</configSections>
<microsoft.web.services2>
<messaging>
<maxRequestLength>3</maxRequestLength>
</messaging>
<diagnostics>
<detailedErrors enabled="true" />
</diagnostics>
</microsoft.web.services2>
</configuration>
In theory, the web service should never let a response over 3kb be
returned. But this just doesn't work.
I can also set this value to 10000 and it won't let me transfer
anything over 4096kb.
Thanks!