WCF Service - Minimum required web.config?

I have a simple WCF service (hosted as my own site in IIS). It was originally developed using .NET 4, but I recently discovered that it needs to be downgraded to .NET 3.5.

I never touched the web.config file and it just worked. Now that I have changed the project from .NET 4 to 3.5, I get configuration errors. The first one was multipleSiteBindingsEnablednot recognized - a quick search tells me that this is new in .NET 4, so I just deleted it. Now the error I am getting is:

The MyService service has zero application endpoints (no infrastructure). Perhaps this is because the configuration file was not found for your application, either because no service element matching the service name was found in the configuration file, or because no endpoints were defined in the service element.

I just want the service to respond, so I can check how to shoot it. The system that will consume the service does not yet exist (it is currently being developed by the state department), so when it is closer to completion, we will worry about the configuration that will be required for its entry into production, etc. What is the minimum configuration that I need in web.configorder for it to work for testing?

+3
source share
1 answer

You need these basic nodes in your web.config service files usually. Of course, the binding types / debub config / etc are for testing purposes only. You must fine-tune it according to your needs.

<system.serviceModel>
        <services>
            <service name="A.B.C.D" behaviorConfiguration="returnFaults">
                <endpoint contract="A.B.C.ID" binding="basicHttpBinding" address=""/>
            </service>
        </services>
        <bindings>
            <basicHttpBinding>
                <binding name="HttpBinding" maxReceivedMessageSize="2097152">
                </binding>
            </basicHttpBinding>
        </bindings>
        <behaviors>
            <serviceBehaviors>
                <behavior name="returnFaults">
                    <serviceDebug includeExceptionDetailInFaults="true"/>
                    <serviceMetadata httpGetEnabled="true"/>
                </behavior>
            </serviceBehaviors>
        </behaviors>
    </system.serviceModel>
+9
source

Source: https://habr.com/ru/post/1776379/


All Articles