0

I have a WPF/WCF application in which I have used external web service by referring .asmx URL in my solution's Service References folder.

At server side, I have created entries in web.config as below:

<binding name="ExtractService" 
     closeTimeout="00:01:00" openTimeout="00:01:00" 
     receiveTimeout="00:01:00" sendTimeout="00:10:00" 
     allowCookies="false" bypassProxyOnLocal="false" 
     hostNameComparisonMode="StrongWildcard" 
     maxBufferSize="2147483647" maxBufferPoolSize="524288" 
     maxReceivedMessageSize="2147483647"  
     messageEncoding="Text" textEncoding="utf-8" 
     transferMode="Buffered" useDefaultWebProxy="true">
    <readerQuotas maxDepth="32" maxStringContentLength="8192" 
           maxArrayLength="2147483647" maxBytesPerRead="4096" 
           maxNameTableCharCount="2147483647" />
    <security mode="Transport">
        <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
        <message clientCredentialType="UserName" algorithmSuite="Default" />
    </security>
</binding>
<client>
    <endpoint name="ExtractService" 
        address="https://example.com/DataExtractService.asmx" 
        binding="basicHttpBinding" bindingConfiguration="ExtractService" 
        contract="ExtractService" />
</client>

Also I have an app.config entry at client side same as web.config above.

Everything works fine when I run it in development environment. Maybe because my client and web server (WCF) are on the same machine.

But when I deploy the app on my test server, it starts giving below error. The client is on my machine and the server (WCF) is on other machine in this case.

Message: HandlingInstanceID: 71a85aef-dbb0-4c28-9035-57f8b7526ee0
An exception of type 'System.ServiceModel.EndpointNotFoundException' occurred and was caught.

There was no endpoint listening at https://example.com/DataExtractService.asmx that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.

To solve this, I tried to copy the same configuration in app.exe.config file at client side, but it does not work.

Where am I missing the client configuration? I also copied the app.config in server's bin folder, but did not help.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Anil Soman
  • 2,443
  • 7
  • 40
  • 64

1 Answers1

1
  • The server side should contain a section <services> that defines what services are available at which endpoints on this server (there has to be at least ONE <service> subsection, which defines at least ONE endpoint where this service is available at - could be multiple, too).

  • The client side should then contain a section <client> that connects to one of those available endpoints.

Or in brief: if you have no section <services> in your server-side config, then you have not exposed any endpoints to connect thus, thus leading to this error.

So your server-side config ought to look something like this:

<!-- Behavior is optional - maybe you need to define something, maybe not -->
<behaviors>
    <serviceBehaviors> 
        <behavior name="ExtractServiceBehavior">
          .....
        </behavior>
    </serviceBehaviors>
</behaviors>
<!-- Binding is the same as defined on the client -->
<binding name="ExtractService" ....
     ......
</binding>
<!-- Define all your services that you offer -->
<services>
    <service name="ExtractService"
             behaviorConfiguration="ExtractServiceBehavior">
        <endpoint name="ExtractService" 
            address="https://example.com/DataExtractService.asmx" 
            binding="basicHttpBinding" 
            bindingConfiguration="ExtractService" 
            contract="IExtractService" />
    </service>    
</services>    

Also: typically, your contract should be an interface (IExtractService) - not a concrete class that implements that interface.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • Thanks for details. I defined the server tag with matching contract etc. However it still gives same error. I also wonder how does it work in development environment then? – Anil Soman Jun 27 '16 at 04:48
  • Wouldn't default endpoints (WCF 4.0+) make "if you have no section in your server-side config, then you have not exposed any endpoints to connect thus" incorrect? – Tim Jun 27 '16 at 07:03
  • 1
    @Tim: you're most likely right..... I keep forgetting those, and I quite frankly find them more confusing and "unexpectedly surprising" than explicitly defining my endpoints..... – marc_s Jun 27 '16 at 12:11
  • 1
    I finally found the reason. Actually the web server was not having internet access enabled on it. After allowing it via our proxy it started working! Because my service address is an external IP. – Anil Soman Jun 27 '16 at 17:46