Tutorial :Configuring a web service endPoint and contract from C# code?



Question:

Edit: I decided to just convert this to a normal web page, as I only need to provide one integer parameter and retrieve a string.

I'll leave the question open if anyone has a good answer.


I have a web service that I want to call, but because this must be called from a plugin to another system, an application config file with all the configuration in won't do, as the plugin system doesn't read that file at all, just the DLL.

So, the question is, how can I take the relevant parts from the config file and translate this to code instead?

The parts I probably need to convert are:

<system.serviceModel>      <bindings>          <basicHttpBinding>              <binding name="TooltipServiceSoap" 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://localhost:2952/TooltipService.asmx"              binding="basicHttpBinding" bindingConfiguration="TooltipServiceSoap"              contract="TooltipService.TooltipServiceSoap" name="TooltipServiceSoap" />      </client>  </system.serviceModel>  

The URL and such will of course change, but that's for me to figure out if someone can just point me in the right direction on how to get the necessary code into the application so that if I delete the application config file, it will still work.


Solution:1

This is on a similar issue and might help: Making WCF easier to configure

I wanted to have an application with little or no client config required - just point it at the server and have it connect.


Solution:2

I used following configuration in web.config file for uploading file size more than 64 KB(Default) through REST Service.

<system.serviceModel>      <services>        <service name="Service">          <endpoint            address=""            binding="webHttpBinding" bindingConfiguration="FileTransferServicesBinding"            contract="IService"/>        </service>      </services>      <bindings>        <webHttpBinding >          <binding name="FileTransferServicesBinding" maxBufferSize="10242880"  maxReceivedMessageSize="10242880">            <readerQuotas maxStringContentLength="10242880"  maxArrayLength="10242880" />          </binding>        </webHttpBinding>      </bindings>    </system.serviceModel>      <system.web>      <httpRuntime maxRequestLength="65536" executionTimeout="36000"/>  </System.Web>  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »