Link to home
Start Free TrialLog in
Avatar of bissellGR
bissellGR

asked on

The maximum string content length quota (8192) has been exceeded

Hi,

I have a classic asp site that connects to WCF using Moniker. It works fine with 8192 bytes message size. But then when it starts sending large data then we get the "The maximum string content length quota (8192) has been exceeded".

I read through different solutions online and tried what they suggested but didn't work. I'm new to WCF so I'm not sure where the changes need to be made and I don't know what the moniker binding, contract etc.... correspond to in the WCF web.config. I have dealt with asp.net site where it is easy to set the configuration on the bindings but it is different in classic asp.

I don't think there is any machine.config changes that were made as far as I know to make this work. The code below works fine but not for large messages.

Here is the code for the moniker in the asp page:

Function GetWsdlMoniker(username, password)
 
    dim strWsdl
    dim wsdlMoniker
    dim monikerProxy

     strWsdl = GetWsdlFromUrl("http://localhost/LegacyService.svc?wsdl")

   wsdlMoniker = "service4:address='http://localhost/LegacyService.svc?wsdl'"
	wsdlMoniker = wsdlMoniker + ", wsdl='" & strwsdl & "'"
	wsdlMoniker = wsdlMoniker + ", binding=CustomBinding_ILegacyService, bindingNamespace='https://WCF/LegacyService'"
	wsdlMoniker = wsdlMoniker + ", contract=ILegacyService, contractNamespace='https://WCF/LegacyService'"

    on error resume next	
   
    Set monikerProxy = GetObject(wsdlMoniker)  

    monikerProxy.ChannelCredentials.SetUserNameCredential username, password
    Set GetWsdlMoniker = monikerProxy

End Function


Function GetWsdlFromUrl(strUrl)  
    Dim WinHttpReq, resp
    Set WinHttpReq = CreateObject("WinHttp.WinHttpRequest.5.1")
    resp = WinHttpReq.Open("GET", strUrl, False)
    WinHttpReq.Send
    GetWsdlFromUrl = WinHttpReq.ResponseText
End Function	


Thank you for your help
Avatar of Vadim Rapp
Vadim Rapp
Flag of United States of America image

Avatar of bissellGR
bissellGR

ASKER

Where on the client side would I increase the limit? It is an asp site and like I mentioned in my post I'm not sure which binding configuration the asp site is using? How can I specify which one to use?
If you can give me code example for both client and server side that would be great.

Thank you so much
You are right, let's worry about the client site later. For now, can you do it on the server side, maybe it will be enough. If not, will have to look how to make it in classic ASP.
I have increased the readerquotas as well as the maxReceivedMessageSize on different bindings on the Server side as this WCF is being used by other .net web sites as well which fixed the issues for many other .net sites but it didn't fix the classic asp site which makes me think that asp is still using the default binding configuration as i didn't specify which one to use.
it looks like this is limitation of winhttp, there's no similarly-named option in WinHttpOptions. Make sure you are using 5.1, there were some enhancements. If does not help, then you'll probably have to rewrite in .net.
:( we don't have the time we need, to rewrite in .net.

Can you just show me exactly the code that you would have on the server side to increase the limit? Maybe I missed something in the config file for the WCF.

Is there a way to connect classic asp to WCF other than the way I'm doing it?
like here

        <binding
            name="myBinding"
            maxReceivedMessageSize="2147483647">
          <readerQuotas
            maxDepth="2147483647"
            maxStringContentLength="2147483647"
            maxArrayLength="2147483647"
            maxBytesPerRead="2147483647"
            maxNameTableCharCount="2147483647" />
        </binding>
how would the classic asp knows that it needs to use the "mybinding" ? Where would you specify it in the asp page? would it go in place of "CustomBinding_ILegacyService"?

Function GetWsdlMoniker(username, password)
 
    dim strWsdl
    dim wsdlMoniker
    dim monikerProxy

     strWsdl = GetWsdlFromUrl("http://localhost/LegacyService.svc?wsdl")

   wsdlMoniker = "service4:address='http://localhost/LegacyService.svc?wsdl'"
&#9;wsdlMoniker = wsdlMoniker + ", wsdl='" & strwsdl & "'"
&#9;wsdlMoniker = wsdlMoniker + ", binding=CustomBinding_ILegacyService, bindingNamespace='https://WCF/LegacyService'"
&#9;wsdlMoniker = wsdlMoniker + ", contract=ILegacyService, contractNamespace='https://WCF/LegacyService'"

    on error resume next&#9;
   
    Set monikerProxy = GetObject(wsdlMoniker)  

    monikerProxy.ChannelCredentials.SetUserNameCredential username, password
    Set GetWsdlMoniker = monikerProxy

End Function
http://social.msdn.microsoft.com/forums/en-US/wcf/thread/bb9d0a2b-d7ed-4012-b365-02605b971383 mentions something called PocketSOAP. Maybe it's an alternative, although I'm not sure if rewriting in it would require less time than in .net.
the comment with <binding was about the server configuration, not client.
Yes correct binding is on the server side. But the code I have in asp specifies the binding name as well. I guess my question is how would you connect to a WCF using moniker, how would you define the binding, etc...It is true that my code works fine (something I didn't write i'm just supporting) so I would like to understand the connection between WCF web.config file and the asp page? Which configuration file does the moniker uses?
The server is written in .net, so it's looking into its own server-side config.

The moniker is on the client side, which is not in .net, so it's not using config, which means that 8192 limit is hardcoded somewhere inside, and there's no way to change it, unless you are capable of hacking binaries. It's all only guesses of course, since it's not documented. You can open tech support incident with Microsoft and find out for sure, if you have about $300 to spare (although there's high probability that they would waive the charge because it's undocumented limitation).

That said, all you need it to open wsdl webpage and read its content - which you can do even in browser. Winhttp is not the only component that can read webpages, you can use xmlhttp, or even webbrowser object

Or, simply download the wsdl manually and use as file - it probably does not change every day. This will even give you performance gain.
There must be a way :( I will wait maybe someone will have an aswer with details on how to exactly do it. Thank you for trying though. I will keep poking with it.
I guess, you'd find xmlhttp almost identical to winhttp. I'd definitely try it first.
But will this fix the issue of sending large data?
We  know that winhttp has this limit hardcoded. .Net client has it configurable. Other clients, such as xmlhttp, may or may not have this limitation. The only way to find out reliably is to try it out. Trying xmlhttp, I guess, will require minimal effort because of its similarity. If it turns out that it does not have this limit, then problem solved.
Unfortunately the xmlhttp request didn't work. I still get the same error.
Then try webbrowser. Or, as we suggested, simply take the wsdl manually, and use it, without retrieving it every time. Since you take it from your own localhost, shouldn't be a problem to update it when you actually update it.
I guess I'm not really sure about your suggestion. I have put localhost in my example just as example. My WCF sits on a server different than my client. Also, is really the issue with the way Im opening/retrieving the WSDL? Isn't the issue the way I'm connecting to the WCF and sending the data through it? I think the issue is in the code below. The strwsdl is the actual wsdl if you are suggesting to put the whole wsdl in there that is fine but this again will not solve the real issue.

wsdlMoniker = "service4:address='https://whatever.com/v2/legacyservice.svc'"
      wsdlMoniker = wsdlMoniker + ", wsdl='" & strwsdl & "'"
      wsdlMoniker = wsdlMoniker + ", binding=CustomBinding_ILegacyService, bindingNamespace='https://test1/LegacyService'"
      wsdlMoniker = wsdlMoniker + ", contract=ILegacyService, contractNamespace='https://test1/LegacyService'"      

Thank you
ASKER CERTIFIED SOLUTION
Avatar of Vadim Rapp
Vadim Rapp
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I will close this question since I didn't get a resolution. I will reward vadimrapp1 for trying to help. Thank you
Unfortunately I was not given a resolution.