0

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>
Community
  • 1
  • 1
Grentley
  • 315
  • 3
  • 6
  • 19
  • What binding do you have your service , is it BasicHTTPonly?? – Coder1409 Apr 09 '15 at 09:13
  • I have defined other bindings as well, ex. Https. As default the service is using basicHttpBinding. – Grentley Apr 09 '15 at 09:18
  • if you have the contract definition just use it in your project with Channel factory and you can use all endpoints you have added to your server in code – Coder1409 Apr 09 '15 at 09:23
  • An solution is to add your tcp, https endpoint to your web.config, when you call your service calculator just specify your endpoint name – Coder1409 Apr 09 '15 at 09:35

0 Answers0