I am new to the C# world, just giving a heads up, because I know...I am probably going to some novice-like stuff, so apologies in advance. Here is my problem:
I have a CLR that calls a web service. The data returned from the web service gets too large for the CLR to handle and generates the following error:
Msg 6522, Level 16, State 1, Line 1
A .NET Framework error occurred during execution of user-defined routine or
aggregate "fnGetReportData":
System.Web.Services.Protocols.SoapException:The formatter threw an exception
while trying to deserialize the message: There was an error while trying to
deserialize parameter http://tempuri.org/:xmlTags.
The InnerException message was 'There was an error deserializing the object of type
System.Collections.Generic.List`1[[System.String, mscorlib, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089]]. The maximum string content
length quota (8192) has been exceeded while reading XML data. This quota may be
increased by changing the MaxStringContentLength property on the
XmlDictionaryReaderQuotas object used when creating the XML reader. Line 1, position
9474.'. Please see InnerException for more details.
System.Web.Services.Protocols.SoapException:
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage
message, WebResponse response, Stream responseStream, Boolean asyncCall) at
System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName,
object[] parameters) at myService.RequestReport(String reportName, String[] xmlTags,
String encryptedUserName, String encryptedPassword)
at myReportClr.UserDefinedFunctions.fnGetReportData(SqlString reportName,
SqlString project, SqlXml reportTags, SqlString userName, SqlString password)
I have looked through some of the other posts with similar length quota errors, but most of the suggestions involve changing the app config. Because I am using a CLR, i do not have an app config and i am not sure if i can add an app config. I tried adding one using the instructions found on LINK but that is for a non-CLR project.
Help is kindly appreciated. Thanks in advance.
Here is a snippet of code to complement the error.
The exception comes up in the SQL Server side within the following function call:
SELECT @reportData = (dbo.fnGetReportData
('DataCompare'
,@projectName
,@harnessXmlTags
,@user
,@password)
);
The code below is from c#. The XML returned is too large and results in the exception at the top of this post:
public static SqlXml fnGetReportData(
SqlString reportName
, SqlString project
, SqlXml reportTags
, SqlString userName
, SqlString password
)
{
String xmlResponse = " ";
SqlXml reportData = SqlXml.Null;
List<String> xmlTags = new List<String>();
xmlTags.Add(CreateTag("Project", project.ToString()));
xmlTags.Add(CreateTag("Configuration", "any"));
xmlTags.Add(reportTags.Value);
using (myService client = new myService())
{
xmlResponse =
client.RequestReport(reportName.ToString()
, xmlTags.ToArray()
, userName.ToString()
, password.ToString()
);
}
if (xmlResponse != null || !xmlResponse.Equals(""))
{
reportData = convertStringtoSqlXml(removeSoapHeader(xmlResponse, reportName.ToString()));
}
else
{
reportData = convertStringtoSqlXml(
String.Format("{0} xmlns:xsi=\"www.myReport.com/myData\" xmlns:ns=\"uri\"", reportName)
);
}
return reportData;
}