Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 604
Lasse V. Karlsen Avatar asked Mar 27 '09 08:03

Lasse V. Karlsen


People also ask

What is an endpoint contract?

A binding that specifies how a client can communicate with the endpoint. A contract that identifies the operations available.

What is endpoint in web config?

The EndpointAddress class represents a WCF Endpoint Address. The Endpoint's Binding specifies how the Endpoint communicates with the world including things like transport protocol (e.g., TCP, HTTP), encoding (e.g., text, binary), and security requirements (e.g., SSL, SOAP message security).

What is service endpoint in C#?

The service endpoint contains the information about the address, binding, contract, and behavior required by a client to find and interact with the service at this endpoint.

What is a Web service endpoint?

A web service endpoint is an entity, processor, or resource that can be referenced and to which web services messages can be addressed. Endpoint references convey the information needed to address a web service endpoint. Clients need to know this information before they can access a service.


2 Answers

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>
like image 173
Avanish GUpta Avatar answered Sep 24 '22 15:09

Avanish GUpta


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.

like image 33
Keith Avatar answered Sep 22 '22 15:09

Keith