I have the following app.config section that I need to translate into code. I have seen several examples, but still cannot quite get it to work. Could anyone help?
<system.serviceModel> <bindings> <basicHttpBinding> <binding name='MyService' 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='TransportWithMessageCredential'> <transport clientCredentialType='None' proxyCredentialType='None' realm='' /> <message clientCredentialType='UserName' algorithmSuite='Default' /> </security> </binding> </basicHttpBinding> </bindings> <client> <endpoint address='https://server.com/service/MyService.asmx' binding='basicHttpBinding' bindingConfiguration='MyService' contract='MyService.MyServiceInterface' name='MyService' /> </client> </system.serviceModel>
My use case is that I am writing a dll that will be used by other non-.net applications, and henceforth I have no good place to put the app.config.
Thanks!
You could use something like this (it looks like pretty standard basicHttpBinding):
This works as long as you have a DLL which contains the contract (‘MyService.MyServiceInterface’) available and you can reference it in your client.
If you need this on the service side, you’ll have to use some different classes etc – but the basics are the same (create a binding, create one or more endpoint addresses, bind them).
Marc
PS: Sorry, I just noticed you use a https:// address – that might require some additional security configuration in code.