I am currently receiving an error "Maximum length exceeded" when calling a web service method that returns a list of objects. I have not found any configuration entry to set the response max length. If I call the web service (http://localhost/test/locations.asmx) and invoke a test on the method, all works correctly. If I call the web service via the javascript proxy, I receive the error. Does anyone have any ideas? Am I missing something? See code below:
Page:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<script type="text/javascript" language="javascript">
function getLocations(code) {
debug.trace("calling web service for return locations");
Locations.GetReturnLocations(code, locationSearchComplete, onError, code);
}
function locationSearchComplete(result, userContext, methodName) {
debug.trace("return location complete");
var results = $get("results");
if (results) {
results.innerText = result;
}
}
function onError(error, userContext, methodName) {
debug.trace(error.get_message());
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Services>
<asp:ServiceReference path="~/Locations.asmx" />
</Services>
</asp:ScriptManager>
<div>
<button id="go" type="button" onclick="javascript:getLocations('dfw');">Go</button>
<br />
<div id="results"></div>
<br />
<br />
<div style="float:right;">
<textarea cols="50" rows="10" id="TraceConsole"></textarea>
</div>
</div>
</form>
</body>
</html>
Web Service:
using System;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Text;
using System.Collections;
using System.Collections.Generic;
/// <summary>
/// Summary description for Locations
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[Microsoft.Web.Script.Services.ScriptService]
public class Locations : System.Web.Services.WebService {
public Locations () {
//Uncomment the following line if using designed components
//InitializeComponent();
}
[WebMethod]
public List<string> GetReturnLocations(string code) {
List<string> loc = new List<string>();
StringBuilder sb = new StringBuilder();
sb.Append("aaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbcccccccccccccccccccccccccccccccdddddddddddddddddddddddd");
sb.Append("eeeeeeeeeeeeeeeeeeeffffffffffffffffgggggggggggggghhhhhhhhhhhhiiiiiiiiiiiijjjjjjjjjjjkkkkkkkkkkkkkkkkkkkkkk");
sb.Append("lllllllllllllmmmmmmmmmmmmmmnnnnnnnnnnnnnnnnnooooooooooooooppppppppppppppppppqqqqqqqqqqqqqqqrrrrrrrrrrrrrrr");
sb.Append("sssssssssssssssttttttttttttttttuuuuuuuuuuuuuuuuuvvvvvvvvvvvvvvvvvvvvwwwwwwwwwwwwwwwwwwwwxxxxxxxxxxxxxxxxxx");
sb.Append("yyyyyyyyyyyyyyyyyyyyyyyyyyyyyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz");
sb.Append("aaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbcccccccccccccccccccccccccccccccdddddddddddddddddddddddd");
sb.Append("eeeeeeeeeeeeeeeeeeeffffffffffffffffgggggggggggggghhhhhhhhhhhhiiiiiiiiiiiijjjjjjjjjjjkkkkkkkkkkkkkkkkkkkkkk");
sb.Append("lllllllllllllmmmmmmmmmmmmmmnnnnnnnnnnnnnnnnnooooooooooooooppppppppppppppppppqqqqqqqqqqqqqqqrrrrrrrrrrrrrrr");
sb.Append("sssssssssssssssttttttttttttttttuuuuuuuuuuuuuuuuuvvvvvvvvvvvvvvvvvvvvwwwwwwwwwwwwwwwwwwwwxxxxxxxxxxxxxxxxxx");
sb.Append("yyyyyyyyyyyyyyyyyyyyyyyyyyyyyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz");
for (int i = 0; i < 100; i++)
{
loc.Add(sb.ToString());
}
return loc;
}
}