Question

I have been staring at the web.config way to long, could you guys have a look?

Running service.Endpoint.Address.ToString() gives me the expected result: http://localhost:2867/Service1.svc and http://localhost:2867/Service1.svc?wsdl gives me all the methods I need.

If you need more info/code i'd be happy to add it.

Thanks for having a look!


The Error

There was no endpoint listening at http://localhost:2867/Service1.svc that could accept the message. This is often caused by an incorrect address or SOAP action.

Client config

<?xml version="1.0" encoding="utf-8"?>    
<configuration>
  <appSettings>
    <add key="webpages:Version" value="2.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="PreserveLoginUrl" value="true" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
  </appSettings>    
  <system.web>        
    <httpRuntime targetFramework="4.5" />        
    <compilation debug="true" targetFramework="4.5" />    
    <pages>
      <namespaces>
       ...
      </namespaces>
    </pages>
  </system.web>    
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />         
  <handlers>
  ...    
  </handlers>
  </system.webServer>    
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_IService1" />
        <binding name="Identity Management WebserviceSoap">
          <security mode="Transport" />
        </binding>
        <binding name="Identity Management WebserviceSoap1" />
      </basicHttpBinding>
    </bindings>    
    <client>
      <endpoint address="http://localhost:2867/Service1.svc" binding="basicHttpBinding"
        bindingConfiguration="BasicHttpBinding_IService1" contract="ServiceReferenceCDP.IService1"
        name="BasicHttpBinding_IService1" />
    </client>
  </system.serviceModel>
</configuration>

Server config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>

  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>

  <system.web>

    <compilation debug="true" targetFramework="4.0">
      <assemblies>
        <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      </assemblies>
    </compilation>

    <httpRuntime targetFramework="4.0" />
    <authorization>
      <allow users="?" />
    </authorization>

  </system.web>

  <system.serviceModel>    
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />

    <client>
      <!--<endpoint address="https://services.howest.be/Howest.Identity.Web.Service/v1.1/facade.asmx" binding="basicHttpBinding" bindingConfiguration="Identity Management WebserviceSoap" contract="BamaFlex.IdentityManagementWebserviceSoap" name="Identity Management WebserviceSoap" />-->
    </client>

    <services>
      <service name="CollectiveDistributedPolling.Service1" behaviorConfiguration="ServiceBehavior">
        <endpoint address="" binding="webHttpBinding" behaviorConfiguration="json" contract="CollectiveDistributedPolling.IService1"></endpoint>        
      </service>
    </services>

    <behaviors>
      <endpointBehaviors>
        <behavior name="json">
          <enableWebScript />
        </behavior>
      </endpointBehaviors>


      <serviceBehaviors>
        <behavior name="ServiceBehavior">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>

    <bindings>
      <basicHttpBinding>
        <binding name="Identity Management WebserviceSoap">
          <security mode="Transport" />
        </binding>
      </basicHttpBinding>

      <webHttpBinding>
        <binding>
          <readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxDepth="64" maxNameTableCharCount="2147483647" />
          <security mode="None" />
        </binding>
      </webHttpBinding>
    </bindings>

  </system.serviceModel>

  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />

    <!--Toegevoegd omdat de browser anders nx ontvangt (GET)-->
    <httpProtocol>
      <customHeaders>
        <add name="Access-Control-Allow-Origin" value="*" />
      </customHeaders>
    </httpProtocol>

    <directoryBrowse enabled="true" />

  </system.webServer>

  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
  </entityFramework>

</configuration>

EDIT

<services>
      <service name="CollectiveDistributedPolling.Service1" behaviorConfiguration="ServiceBehavior">
        <endpoint address="http://localhost:2867/Service1.svc" binding="webHttpBinding" behaviorConfiguration="json" contract="CollectiveDistributedPolling.IService1"></endpoint>        
      </service>
    </services>
Was it helpful?

Solution

Two things to check:

  1. Your client is using basicHttpBinding, and your service is using webHttpBinding, so you have a binding mismatch.

  2. Your client is referencing ServiceReferenceCDP.IService1 for the contract and your service is using CollectiveDistributedPolling.IService1 - these are not the same, even if the code is identical.

Remember the ABCs of WCF - Address, Binding and Contract. The client must match the service to connect.

OTHER TIPS

You server side configuration address property contains only an empty string, specify an address in it: http://localhost:2867/Service1.svc

(Please do not use development server for this.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top