Background
I am developing an ASP.Net server control that needs to talk to the ASMX web service. The server-side control uses the WebClient object to talk to the web service because it needs to be reused frequently in various applications, and to simplify the work with developers, they do not need to create a service link for the web service.
Implementation
When using the control, it requires sending the serialized object to the web service. The object is serialized using the XmlSerializer , and the resulting XML string is then compressed using the chilkat compression library. The web service call for management is as follows:
webClient.UploadStringAsync(new Uri(serviceHost + serviceMethod), "POST", sendData)
The contents of sendData ( string ) are compressedResponse={CompressedData} .
The web service has a method defined as follows to retrieve data and then unzip the string value using the chilkat library before de-serializing the object using XmlSerializer .
public void SaveResponse(string compressedResponse)
The connection between the control and the service is working. Initially, there were no settings or bindings defined in web.config for any of the above. After the initial search, I added
<httpRuntime maxRequestLength="20480"/>
for client and web.config server files. It didn't make any difference.
Problem
The compressed or uncompressed data sent to the web service in the sendData variable is large for a regular POST request and is corrupted. This is confirmed by checking the last few characters of the string before and after its publication on the server in a compressed format and without compression, the last root tag is missing from the Xml document when checking in the debugger. string cannot be unpacked, and therefore the service call fails every time.
How to increase the POST size for a WebClient request to ensure that the full string is received by the server?
I looked at various options on Google, but none of them give me a good enough selection of where to make changes, or samples of what the changes should look like. I completely lost the question of whether a change is needed on the server or on the consumption website, and since there is no binding for this, how to create a binding in web.config to call the ASMX HTTP service.