Solved

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

Posted on 2016-11-24
11
30 Views
Last Modified: 2017-01-17
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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
 

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 80

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

685 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