Solved

C# Forms Application not reading binding configuration in App.Config

Posted on 2016-11-24
11
19 Views
Last Modified: 2016-11-29
I have an application which is calling a webservice over https.  I am repeatedly getting "The maximum message size quota for incoming messages (65536) has been exceeded" errors, despite having set this value in the binding.  I have tried custom bindings (throws an error saying it doesn't understand the SoapHeader Action), httpBinding and httpsBinding, all to no avail.  What am I missing?

Screenshot of error and code
code:
<basicHttpsBinding>
              <binding name="ScreenConnectBinding" closeTimeout="00:03:00"
                  openTimeout="00:03:00" receiveTimeout="00:10:00" sendTimeout="00:03:00"
                  maxBufferSize="2000001"
                  maxBufferPoolSize="2000001" maxReceivedMessageSize="2000001">
                <readerQuotas maxDepth="2000001" maxStringContentLength="2000001"
                  maxArrayLength="2000001" maxBytesPerRead="2000001" maxNameTableCharCount="2000001" />
                    <security mode="Transport" />
                </binding>
                
            </basicHttpsBinding>
        </bindings>
        <client>
            <endpoint address="XXXXXXX" bindingConfiguration="ScreenConnectBinding"
                binding="basicHttpsBinding" contract="ws_trilogy.ScreenConnectSoap" name="ScreenConnectSoap" />
        </client>

Open in new window


Thanks
0
Comment
Question by:itfocus
  • 5
  • 5
11 Comments
 
LVL 6

Expert Comment

by:Giuseppe "Pino" De Francesco
ID: 41900426
Hi,

Not seeing the related code I can only assume you are not using that binding name, hence default valued are used by the listener.

Here a few links that can help you:
https://msdn.microsoft.com/en-us/library/ms731862(v=vs.110).aspx
https://msdn.microsoft.com/en-us/library/ms733051(v=vs.110).aspx
https://msdn.microsoft.com/en-us/library/ms733099(v=vs.110).aspx
https://msdn.microsoft.com/en-us/library/ms733932(v=vs.110).aspx
0
 

Author Comment

by:itfocus
ID: 41900491
I'm not sure what you mean?  The code above is from the app.config.  The application itself just uses

       ScreenConnectSoapClient soap = new ScreenConnectSoapClient();
               AuthHeader ah = new AuthHeader { CallingApplication = "XXXX", Username = "D207E6886545ABB0FE18A65DAEFC794384B58F1A804F48ABC3F72D0E8B98D09B", Password = "478277481E0435EB9B92F88BF581B041AACEF6F653B0E8DC959477537782016E" };
                DataSet computers = soap.GetComputersAndScreenConnectSessionID(ah, Globals.ClientID, ref ReturnMessage);

This is how I have always written these sorts of connections, and it works fine.  I have actually just updated the webservice to use https.  Before that it was using http.  I assume this must be the problem, as everything else was identical?
0
 
LVL 6

Expert Comment

by:Giuseppe "Pino" De Francesco
ID: 41900499
Hi,
That's client side code: what's on the server side?
0
 

Author Comment

by:itfocus
ID: 41900516
The receiving end of the code above contains methods which call a further external webservice.  The web.config for the middle site is the same:

   <binding name="ScreenConnectSoap"  closeTimeout="00:15:00" openTimeout="00:15:00"
          receiveTimeout="00:15:00" sendTimeout="00:20:00" allowCookies="false"
          bypassProxyOnLocal="false" maxBufferPoolSize="524288" maxReceivedMessageSize="44265536"
          useDefaultWebProxy="true" />

   <endpoint address="http://XXXXXXXXXXX/Screenconnect.asmx"
        binding="basicHttpBinding" bindingConfiguration="ScreenConnectSoap"
        contract="ws_screenconnect.ScreenConnectSoap" name="ScreenConnectSoap" />

Is that what you meant?
0
 
LVL 6

Expert Comment

by:Giuseppe "Pino" De Francesco
ID: 41900575
Hi, I mean the actual code, not the configuration file. BTW, this last config has a different binding name, so I guess it's some other server?
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

by:itfocus
ID: 41900582
What would I need to put in the actual code?  I have never had to put anything in there before?  

When I run the method on the middleman server, it runs fine, so the data is getting there with no problems, its just from the middle server to the app.  I tried creating a basic test web app to call this webservice, and the same thing is happening.  

I have compared the main webservice code and config with the middle server one, to see if there is anything set differently, but there isn't.

The code itself simply says this:

   /// </summary>
    [WebService(Namespace = "http://ws.trilogytechnologies.ie")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    [System.Web.Script.Services.ScriptService]
    public class ScreenConnect : System.Web.Services.WebService
    {
        public class AuthHeader : SoapHeader
        {
            public string CallingApplication;
            public string Username;
            public string Password;
        }

        public ws_screenconnect.AuthHeader _authHeader = new ws_screenconnect.AuthHeader { CallingApplication = "XXXXXXX", Username = "D207E6886545ABB0FE18A65DAEFC794384B58F1A804F48ABC3F72D0E8B98D09B", Password = "478277481E0435EB9B92F88BF581B041AACEF6F653B0E8DC959477537782016E" };

        public AuthHeader Authentication;

        [SoapHeader("Authentication")]
        [WebMethod]
        public String AuthenticateUser(String Email, String Password, String IPAddress, ref Int32 ClientID, ref String ClientName, ref String LicenceMessage, ref Boolean PermissionRequired)
        {
            ScreenConnectSoapClient soap = new ws_screenconnect.ScreenConnectSoapClient();
            string data = soap.UserAuthenticate(_authHeader, Email, Password, IPAddress, ref ClientID, ref ClientName, ref LicenceMessage, ref PermissionRequired);
            return data;
        }

        [SoapHeader("Authentication")]
        [WebMethod]
        public DataSet GetComputersAndScreenConnectSessionID(Int32 ClientID, ref String ReturnMessage)
        {
            ScreenConnectSoapClient soap = new ws_screenconnect.ScreenConnectSoapClient();
            DataSet results = soap.GetData(_authHeader, ClientID, ref ReturnMessage);
            return results;
        }


(Note, the first method is working fine, as this returns a lot less data!)
0
 
LVL 6

Expert Comment

by:Giuseppe "Pino" De Francesco
ID: 41900627
Hi,

That's odd... have you tried changing the client instancing into this form?

ScreenConnectSoapClient soap = new ScreenConnectSoapClient("ScreenConnectSoap");

Open in new window

0
 
LVL 78

Expert Comment

by:David Johnson, CD, MVP
ID: 41900911
200000 is a lot more than 65535 fix that error first in the max recieved message size
0
 

Accepted Solution

by:
itfocus earned 0 total points
ID: 41901327
I eventually got this working by copy/pasting swathes of the config file I knew to work to the one that wasn't.  Not quite sure which bit or combination of bits did it, but it suddenly started working.  Madness.

Many thanks for your time though, much appreciated.
0
 
LVL 6

Expert Comment

by:Giuseppe "Pino" De Francesco
ID: 41901404
That's odd... I guess some unexpected control character in the config file... old times stuff... I haven't seen such occurrence is years :)
0
 

Author Closing Comment

by:itfocus
ID: 41905461
Found the answer by chance in the end
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

759 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now