Archive

Archive for the ‘Web Services’ Category

Streaming huge results from ASMX

April 20, 2010 Leave a comment

Turns out streaming lots of data from an ASMX web service isn’t too hard. I have to update upwards of 46,000 products from one web site to another over an ASMX service. Initially, I was getting a lot of exceptions:

The request channel timed out while waiting for a reply after 00:01:00. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout.

But that’s easy to fix. In my web.config, I boosted the timeouts from 00:01:00 to 00:10:00. This led to my next exception:

The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element.

I tried to fix this by increasing the maxReceivedMessageSize to 2147483647 (the max size of a signed integer–Int32). But I was still getting weird exceptions, so I knew I hadn’t actually fixed it. The exceptions weren’t showing up until I made my next web service call:

The communication object, System.ServiceModel.ChannelFactory`1[Custom.BLL.Rms.ItemManagement.ItemManagementSoap], cannot be used for communication because it is in the Faulted state.

Turns out this has an easy fix. The problem was that, by default, my binding was using a transfer mode of “Buffered”. This limits the maxReceiveMessageSize. I changed the transferMode to “Streamed”, and boosted the maxReceiveMessageSize to 9223372036854775807 (Int64′s max size).

After updating that, I was able to blissfully make my massive call.

Categories: .NET, ASP.NET, Web Services
Follow

Get every new post delivered to your Inbox.