Solved

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

Posted on 2016-11-24
11
39 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
11 Comments
 
LVL 7

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 7

Expert Comment

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

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

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 7

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 7

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 82

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 7

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

623 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