Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2016-11-24
11
Medium Priority
?
47 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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 83

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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

715 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