.NET Forum / ASP.NET / Web Services / December 2004
File Attachments Larger and 4MB
|
|
Thread rating:  |
Drew Lettington - 01 Dec 2004 23:32 GMT I have .NET Windows .dll attempting to receive a DIME attachement larger than the default value of 4MB. I maxRequestLength to -1 in the Web Service's web.config file. I understand I also need to change the setting on the client side. But, since the client is a .dll, there is no app.config file.
I've solved this issue with other dynamic settings by setting programmatically in the client's reference.cs file. I planned to do the same here but I can't determine which Web Service property is affected by setting maxRequestLength in the app.config file.
Can anyone help?
Martin Kulov - 02 Dec 2004 08:08 GMT Hi Drew,
your .NET dll is hosted by some .exe after all. Create config file for the .exe and place the following in it.
<microsoft.web.services2> <messaging> <maxRequestLength>102400</maxRequestLength> </messaging> </microsoft.web.services2>
HTH, Martin Kulov www.codeattest.com
drkraus - 02 Dec 2004 21:23 GMT Hi Martin,
I am working with Drew. The problem is that the hosting executable is Excel. I have made it work by creating an excel.exe.config file, but this is not a great solution. Drew was trying to find a way to set maxRequestLength programmatically.
Dave
> Hi Drew, > [quoted text clipped - 9 lines] > Martin Kulov > www.codeattest.com rory plaire - 02 Dec 2004 18:43 GMT > I have .NET Windows .dll attempting to receive a DIME attachement larger than > the default value of 4MB. I maxRequestLength to -1 in the Web Service's > web.config file. I understand I also need to change the setting on the > client side. But, since the client is a .dll, there is no app.config file. In the machine.config file for the runtime you are using, you'll find the attribute: maxRequestLength="4096". The value refers to kilobytes, yielding the 4MB ceiling. You need to change or override this.
-rory
Rory Plaire - 02 Dec 2004 20:30 GMT > I have .NET Windows .dll attempting to receive a DIME attachement larger than > the default value of 4MB. I maxRequestLength to -1 in the Web Service's > web.config file. I understand I also need to change the setting on the > client side. But, since the client is a .dll, there is no app.config file. If you check your machine.config file, there is an element named "httpRuntime". Since you mention that this is a web service, I suspect you are hosting it in IIS. If so, then this element applies. It has an attribute named "maxRequestLength". The value by default is 4096, which means 4MB. You'll need to change or override this to get more data in the request.
-rory
Rory Plaire - 02 Dec 2004 20:43 GMT Sorry for the double post... It appears that Google's new groups isn't ready for prime time, yet.
-rory
drkraus - 02 Dec 2004 21:29 GMT Hi Rory,
I am working with Drew. I have tried the httpruntime solution, but this is not enough since putting it in the machine.config, or the web.config of the service, only covers the web server side of things. It appears that this value must also be set for the client. Our client is an Excel add-in, and I have made it work by setting maxRequestLength in a excel.exe.config file that I create, but this is not an optimal solution. We are trying to figure out how to either programmatically set the maxRequestLength value from the client side, or find another way to configure the value which won't require us to put an excel.exe.config file in the Office10 directory.
thanks, Dave
> > I have .NET Windows .dll attempting to receive a DIME attachement larger than > > the default value of 4MB. I maxRequestLength to -1 in the Web Service's [quoted text clipped - 9 lines] > > -rory Rory Plaire - 02 Dec 2004 21:50 GMT > Hi Rory, > [quoted text clipped - 10 lines] > > thanks, Dave Interesting... so excel is the server and you're exposing the WSE Soap Server through an Excel add-in... Is my understanding correct?
You could try to set it through reflection. The class you're looking for is Microsoft.Web.Services2.Messaging.Configuration.MessagingConfiguration, which can be found as a static member of Microsoft.Web.Services2.Configuration.WebServicesConfiguration, and the property you need to set is the integer _maxRequestBytes. Notice that you'll need to specify _bytes_ here instead of kilobytes, like in the configuration file. I'm sure that this is quite a bit not supported, but it may work for you. Since everything is static on the class, you'll need to set this value before you call any WSE code.
It's a good feature request: make the configuration programmatically accessible. If you can set it in the config file, you should be able to set it in code!
-rory
drkraus - 02 Dec 2004 22:35 GMT Excel is the client. An Excel add-in exposes access to our web service.
Thanks, we will take a look at your suggestion...
> > Hi Rory, > > [quoted text clipped - 30 lines] > > -rory drkraus - 03 Dec 2004 02:49 GMT I am not to experience with reflection, so maybe you can give me a hint.
I can access the MessagingConfiguration property that is contained in the WebServicesConfiguration type, but I don't know how to access the static value you talk about (_maxRequestBytes). Is _maxRequestBytes part of the MessagingConfiguration property or the WebServicesConfiguration type? MessagingConfiguration has only one accessor ( the get method). There is no set method here.
> Excel is the client. An Excel add-in exposes access to our web service. > [quoted text clipped - 34 lines] > > > > -rory drkraus - 06 Dec 2004 18:47 GMT I have been able to set _maxRequestBytes via reflection, but am doing so on an instance of MessagingConfiguration that I create. How do I access the running configuration?
thanks, Dave
> I am not to experience with reflection, so maybe you can give me a hint. > [quoted text clipped - 43 lines] > > > > > > -rory Drew Marsh - 06 Dec 2004 19:58 GMT > I have been able to set _maxRequestBytes via reflection, but am doing > so on an instance of MessagingConfiguration that I create. How do I > access the running configuration? <codeSnippet language="C#"> using Microsoft.Web.Services2.Configuration; using Microsoft.Web.Services2.Messaging.Configuration;
.. then ...
WebServicesConfiguration.MessagingConfiguration; </codeSnippet>
I'm still not convinced this will solve the problem, but let us know!
-Dre
drkraus - 07 Dec 2004 01:05 GMT Yes, I was just about to post this as well....
I have verified that I can change the read only property MaxRequestLengthInBytes by accessing the private member _maxRequestBytes. The code is listed below. I need to try this in the client environment in which I am failing to verify that this fixes the problem, but it should...
Here's the code:
//access the current config object MsgConfTypeObj= Microsoft.Web.Services2.Configuration.WebServicesConfiguration.MessagingConfiguration;
//setup the parameter value for call to set _maxRequestBytes. object[] parms=new object[1]; parms[0]= -1; //specified number of bytes. -1 mean unlimited.
//Find and execute a SetField on _maxRequestBytes, setting it to the value of the parm. MsgConfTypeObj.GetType().InvokeMember("_maxRequestBytes", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.SetField, null, MsgConfTypeObj, parms );
Dave Kraus
> > I have been able to set _maxRequestBytes via reflection, but am doing > > so on an instance of MessagingConfiguration that I create. How do I [quoted text clipped - 12 lines] > > -Drew drkraus - 07 Dec 2004 18:35 GMT I have verified that this has solved my problem. What is interesting is that after adding this code for my client, I don't need to configure my server for some reason. The client setting seems to suffice. I tried this using client and web service on different machines as well.
> Yes, I was just about to post this as well.... > [quoted text clipped - 37 lines] > > > > -Drew Drew Marsh - 07 Dec 2004 19:34 GMT > I have verified that this has solved my problem. What is interesting > is that after adding this code for my client, I don't need to > configure my server for some reason. The client setting seems to > suffice. I tried this using client and web service on different > machines as well. Wow. Thanks for sharing your findings. This just seems so drastically wrong that I'm thinking we should report a bug.
I can't believe out of all the threads I see MS representitives posting in they haven't chimed in on this one. :\
-Dre
Drew Marsh - 02 Dec 2004 22:09 GMT > I am working with Drew. I have tried the httpruntime solution, but > this is not enough since putting it in the machine.config, or the [quoted text clipped - 6 lines] > or find another way to configure the value which won't require us to > put an excel.exe.config file in the Office10 directory. That's weird. I wouldn't think that maxRequestLength would affect the client side at all. It's more of a DoS attack protector for the server side. Are you sure you didn't change a couple things at once and end up thinking you needed to do this on the client? Maybe you've already made sure of this, but if not, try removing the config for Excel again real quick now that you know it's working and see what happens.
I don't have time to test this at the moment otherwsie I would try to test it for you.
Later, Drew
drkraus - 02 Dec 2004 22:29 GMT I have tried removing the excel.exe.config file, and I get the failure. The weirder thing was that when I removed the maxRequestLength config stuff from my web.config file, things continued to work, as if the excel.exe.config made it work from both server/client side. Granted I am using client/server from the same machine. I am setting up another machine right now to act as a separate client.
Also, I noticed that removing the excel.exe.config, and then making a config change in machine.config worked. This would mean that I would need to make changes to the machine.config machine of the client. But, again, I need to try this from a separate client to figure this out.
> > I am working with Drew. I have tried the httpruntime solution, but > > this is not enough since putting it in the machine.config, or the [quoted text clipped - 19 lines] > Later, > Drew Drew Marsh - 03 Dec 2004 00:04 GMT > I have tried removing the excel.exe.config file, and I get the > failure. The weirder thing was that when I removed the [quoted text clipped - 8 lines] > need to make changes to the machine.config machine of the client. But, > again, I need to try this from a separate client to figure this out. Ahhh... wait I have a thought for you. Which maxRequestLength are you changing on the server side? There's two to consider if you're using WSE and hosting in ASP.NET. First is the <system.web><httpRuntime>'s maxRequestLength and then there's <microsoft.web.services2><messaging><maxRequestLength>'s. I *think* you'll need to set both of them on the server to get it to work. Setting the former on the client side certainly makes no sense at all since, whether you're using a WSDL or WSEWSDL2 proxy, neither of them should be affected by the <httpRuntime> setting.
I just can't believe that maxRequestLength would affect the client side at all. I wish I had time to whip together a demo to see if I could help u figure it out. Maybe someone from MS will chime in on this thread.
Later, Dre
drkraus - 03 Dec 2004 02:45 GMT Thanks Drew, but I have tried setting both maxRequestLength values in the web.config file and it hasn't worked. However, if I set both values in machine.config, it does work. Since I am running my client on the same machine, I am thinking that the client is also accessing machine.config as well.
My attempts to set up another machine has broken down today, so I haven't been able to explore that angle.
> > I have tried removing the excel.exe.config file, and I get the > > failure. The weirder thing was that when I removed the [quoted text clipped - 24 lines] > Later, > Drew Drew Marsh - 03 Dec 2004 03:01 GMT > Thanks Drew, but I have tried setting both maxRequestLength values in > the web.config file and it hasn't worked. However, if I set both > values in machine.config, it does work. Since I am running my client > on the same machine, I am thinking that the client is also accessing > machine.config as well. Ahhh darn. Figured it was worth making sure. You're right about changing machine.config affecting both the client and server since you're on the same machine.
Hmm... I just wish someone from MS would jump in here and confirm/deny whether or not maxRequestLength affects the client side or not. It certainly sounds that way, but that would seem like a total bug since I don't think there should be any caps on what the client side can send.
Well good luck and be sure to let us know if/when/what you figure out!
Cheers, Dre
Free MagazinesGet these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...
|
|
|