I have added a web reference to a web service. The below configuration has been auto generated in app.config. I found out from the answer to the following question https://stackoverflow.com/a/3704312
that
Usually, when you use the parameterless constructor (i.e. new MyServicesSoapClient()), the settings in the app.config file will be used. However, you can bypass the app.config file by explicitly setting the binding and endpoint values in code and passing those instances into the constructor.
Unfortunately, when I try to do it I keep getting '...does not contain a constructor that takes 2 arguments' error. My question is why my instance of web service doesn't contain constructor with 2 arguments? Is this something to do with wsdl? How do I fix that? I need to have default auto-generated binding and endpoint, but I also need a way of using other bindings (ex. https) and endpoints.
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="MyServicesSoap" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://services.mycompany.com/WebServices/MyServices.asmx"
binding="basicHttpBinding" bindingConfiguration="MyServicesSoap"
contract="MyServices.MyServicesSoap" name="MyServicesSoap" />
</client>
</system.serviceModel>