Limit on the size of SOAP messages?

B

Bruce

I am creating a Windows Forms client app working in conjunction with Web
Services on our Windows 2003 server, for remote file acess. (The files are
serialized into byte[] objects for file xfer in the Web Services messages on
the up/down directions.) During testing today, I noticed that file uploads
to the server seem to fail whenever the enclosed file is larger than about
1-2 Mbytes. Is there some inherent size limit on .NET-generated SOAP
messages? If so, can I modify it, or will I have to do some hoop jumping to
break large files into multiple messages?

A code example is attached. m_Server is the proxy on the client, and
m_Server.Upload() is a Web Services method on the server.

Thanks,
Bruce

------------

public bool UploadAsset( User user, Asset asset, ArrayList
groupNames )

{

byte [] fileBytes; // xml image of the Asset's binary file.

long globalSN = -1L;



FileStream fs = null;

FileInfo inf = new FileInfo( asset.FileSpec );

if ( !inf.Exists )

{

MessageBox.Show( "Error reading file: " + asset.FileSpec );

return false;

}

try

{

fs = new FileStream( asset.FileSpec, FileMode.Open,
FileAccess.Read );

fileBytes = new byte[inf.Length];

fs.Read( fileBytes, 0, (int)inf.Length );

fs.Close();

}

catch ( Exception ex )

{

MessageBox.Show( "Error reading file: " + asset.FileSpec +

", Exception: " + ex.Message );

return false;

}



// Send it up to the server...

try

{

globalSN = m_Server.Upload(user.UserName, user.PassWord,
asset.FileName,

fileBytes, asset.TypeName, asset.Description,

groupNames.ToArray());

asset.SerialNumber = globalSN;

}

catch (Exception ex)

{

// Trigger event to inform subscribers of connectivity failure.

ServerConnEvent(this, new ServerConnEventArgs(false));

}



return (globalSN != -1L);

}
 
R

Robert Wilczynski

Hi Bruce,

This is not about SOAP messages but http requests in general. Try playing
with the maxRequestLength property in the web.config file (or machine.config
if you want to make it a default for all asp.net applications on te server):

<system.web>
<httpRuntime maxRequestLength="10240" />
</system.web>

Above setting should allow the application to accept requests up to 10 MB.
Setting the value consider the additional data that has to be sent with each
SOAP message so the actuall file size limt will be a little lower than the
value you set. Does that help?

Best regards,
Robert Wilczynski.
 
S

Steven Cheng[MSFT]

Thanks for Robert's informative suggestion.

Hi Bruce,

For WebService in ASP.NET, there is no size limitation at SOAP message
layer, the limitation you encountered is likely the ASP.NET httpruntime's
request size limitation. Since the ASP.NET Webservice SOAP message
transmission layers on the ASP.NET httpruntime pipeline, it is also limited
to the ASP.NET httpruntime limitation, and there is a "maxRequestLength"
attribute that control the max size of the HttpRequest message. You can
configure it in your web.config file through the <httpRuntime> element as
Robert has mentioned:

#httpRuntime Element (ASP.NET Settings Schema)
http://msdn2.microsoft.com/en-us/library/e1f13641(VS.80).aspx

In addition, if you just want to enlarge this setting for a particular page
or sub directory:

#location Element (ASP.NET Settings Schema)
http://msdn2.microsoft.com/en-us/library/b6x6shw7(VS.80).aspx

Hope this also helps.

Regards,

Steven Cheng
Microsoft Online Community Support


==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================


This posting is provided "AS IS" with no warranties, and confers no rights.



Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
B

Bruce

Thanks Robert and Steven,
I am investigating your recommendations. I think that is just what I
needed.
-- Bruce
 
S

Steven Cheng[MSFT]

Thanks for your response Bruce,

Glad that those suggestion are of assistance. Please feel free to post here
when there is anything we can help you.

Regards,

Steven Cheng
Microsoft Online Community Support


==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================


This posting is provided "AS IS" with no warranties, and confers no rights.



Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top