Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How can I increase the allowed size of the string returned by a web service?

Posted on 2010-09-22
2
495 Views
Last Modified: 2012-06-21
I have a asp.net web application in which a JavaScript call is made to a web service which is written in VB.  The web service accesses a data set which is in a session variable and returns it as XML.  For most users the returned XML is a few thousand characters but for some it can be over 800,000.  When the XML is somewhere over 55,000 charactersI get this error, "Error: Sys.Net.WebServiceFailedException: The server method failed with the following error: -- There was an error processing the request.".  The error occurs in the depths of the auto generated JavaScript so I haven't had much luck debugging it however it is apparent that there is a default limit on the size of the string returned by web services.  I searched the web and found some things about disabling SOAP and setting the JSON size limit in web.config but that didn't work for me.  The code for the JavaScript and the web service are below.  Any suggestions would be greatly appreciated.
function PopulateRecordsFor() 
{
    try
    {
    RecordsForService.PopulateList(PopulateRecordsForCallBack);
    }
    catch (e) 
    {
        alert("Alert 1" + e.description);
    }
}

function PopulateRecordsForCallBack(result)
{
    try {
        var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
        xmlDoc.async = "false";
        xmlDoc.loadXML(result);
        var xmlname, xmlid
        var findNodes1 = xmlDoc.getElementsByTagName("Name");
        var ddl = $get("ctl00_ddlRecordsFor");
        for (i = 0; i < findNodes1.length; i++) {
            xmlname = xmlDoc.getElementsByTagName("Name")[i].childNodes[0].nodeValue;
            xmlid = xmlDoc.getElementsByTagName("FileNumber")[i].childNodes[0].nodeValue;
            var objOption = document.createElement("option");
            objOption.value = xmlid;
            objOption.text = xmlname;
            ddl.add(objOption);
        }
    }
    catch (e) 
    {
        alert("Alert 2" + e.description);
    }
}

Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Data
Imports System.Collections.Generic

<System.Web.Script.Services.ScriptService()> _
<WebService(Namespace:="http://People-Inc.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class RecordsForService
    Inherits System.Web.Services.WebService

    <WebMethod(EnableSession:=True)> _
    Public Function PopulateList() As String
        Try
            Dim ds As DataSet = Session("CurrentUser").Individuals
            Return ds.GetXml()
        Catch ex As Exception
            Return "The following error has occurred on the Core Information form while attempting to populate the Records For list.' " _
             & ex.Message & "' Copy and paste this message into an e-mail to the IT help " _
             & "desk or call the IT help desk and read this exact message to them."
        End Try
    End Function

End Class

Open in new window

0
Comment
Question by:leskelly
2 Comments
 
LVL 2

Accepted Solution

by:
SandyAgo earned 500 total points
ID: 33734335
Hi leskelly,

There is a max size that a web service will return. You can set the size to the max nby putting this in your web config file:

<system.web.extensions>
		<scripting>
			<webServices>
				<jsonSerialization maxJsonLength="2147483647"></jsonSerialization>
			</webServices>
		</scripting>
	</system.web.extensions>

Open in new window

0
 

Author Closing Comment

by:leskelly
ID: 33735278
Hello SandyAgo,

I had tried that but apparently I got the syntax wrong or something because once I copied and pasted what you wrote it worked.  Thanks for you help.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to resize a div in html 3 35
Name Space error VS2015 1 22
jQuery force form POST 7 42
asp Google Map 2 23
These instructions are based on installing Owncloud on your new raspberry pi connected with a usb HDD. What do you need Part A? A Raspberry Pi, model B. A boot SD card for the Raspberry Pi. A usb HDD An Ethernet cable to connect to the lo…
New Relic recently released its Synthetics product that allows for the creation of performance monitors that periodically test a site's performance. If you wish to test an interactive workflow New Relic employs Selenium WebDriverJS to run those test…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

790 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question