Solved

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

Posted on 2016-11-24
11
32 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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 

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 81

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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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 Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

752 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