Search code examples
.netwcfwcf-bindingendpoint

Could not find default endpoint element .NET 4.0


I've added a proxy to a webservice to a VS2010/.NET 4solution. My machine is windows 7 OS. When constructing the client .NET throws this error:

Could not find endpoint element with name 'FulfilmentServicesSoap' and contract 'FulfimentServiceSoap.FulfilmentServicesSoap' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this name could be found in the client element.

I have found a simlar type question on SO here:

Could not find default endpoint element

However reading through this and attempting some of the answers has not worked for me. I have edited the app.config file a number of times including:

contract="IFulfimentServiceSoap" name="FulfilmentServicesSoap" />

and

contract="FulfimentServiceSoap.FulfilmentServicesSoap" name="FulfilmentServicesSoap" />

and

contract="MYFullNamespace.FulfimentServiceSoap.FulfilmentServicesSoap" name="FulfilmentServicesSoap" />

However in each case when I run my web service the event viewer show the contract 'FulfimentServiceSoap.FulfilmentServicesSoap' even when i have edited the config file. Is there something else I must do to pick up the changes in the app.config file or has anyone any other ideas?

EDIT - added binding info from app.config

<system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="FulfilmentServicesSoap" 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/WLR3.Web.services/FulfilmentServices.asmx"
                binding="basicHttpBinding" bindingConfiguration="FulfilmentServicesSoap"
               contract="FulfimentServiceSoap.FulfilmentServicesSoap"name="FulfilmentServicesSoap" />
        </client>
    </system.serviceModel>

EDIT - code where client is created.

FulfimentServiceSoap.FulfilmentServicesSoap fulfilmentServices = new FulfimentServiceSoap.FulfilmentServicesSoapClient("FulfilmentServicesSoap");

Solution

  • Ok so figured this out for me anyway - will post here in case it helps anyone else. The DLL was created I copied to my Application/Libraries folder. (I didnt copy the app.config file that was created). In the code where I create the client I coded the binding and Endpoint address details and then passed them in to the SoapClient constructor. So my code for that looked as below:

    BasicHttpBinding binding = new BasicHttpBinding();
    EndpointAddress remoteAddress = new EndpointAddress("http://localhost/WLR3.Web.services/FulfilmentServices.asmx");
    binding.Name = "FulfilmentServicesSoap";
    binding.AllowCookies = false;
    
    FulfimentServiceSoap.FulfilmentServicesSoap fulfilmentServices = new FulfimentServiceSoap.FulfilmentServicesSoapClient(binding, remoteAddress);