9

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.

GEOCHET
  • 21,119
  • 15
  • 74
  • 98
Lasse V. Karlsen
  • 380,855
  • 102
  • 628
  • 825
  • WCF, has as much pain from configuration as it gains... in some ways, the old WSE/WSDL web-services are a lot simpler - or even things like protobuf-net provide contract-based RPC/http channels. You can do WCF entirely through code, but it isn't always simple. – Marc Gravell Mar 27 '09 at 09:32
  • I found several web pages, but it seemed like black magic, so I just converted the current code to a web page instead. I just need a pure text string from an ID, and the "service" is just there to separate some systems from each other due to security concerns. – Lasse V. Karlsen Mar 27 '09 at 11:07

2 Answers2

3

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>
Jérôme Verstrynge
  • 57,710
  • 92
  • 283
  • 453
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.

Community
  • 1
  • 1
Keith
  • 150,284
  • 78
  • 298
  • 434