2

I have this scheme:

IIS

  • hosts: OperatorService.svc (connects to ClientService)
  • Global.asax (on start): hosts ClientService via ServiceHost

WPF client

  • connects to ClientService


If I go to OperatorService the service is activated, web application started, and ClientService is successfully hosted at http://localhost:8020/ClientService. So far so good.

I can now access the ClientService in the aforementioned URL in a browser, I can add it through Add Service Reference. It's simply there - running.

But when I try to connect via generated client (looks OK), it suddenly doesn't work. Throwing:

There was no endpoint listening at http://localhost:8020/ClientService that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.

Moreover the OperatorService connects to this ClientService itself (it is a WsDualHttpBinding to provide notifications). It subscribes itself correctly to this service (calling a method) and it works (same URL as my WPF client).

Why can't I connect from my WPF client?

WPF client config (only relevant sections):

<client>
    <endpoint address="http://localhost:8020/ClientService" binding="wsDualHttpBinding"
        bindingConfiguration="DefaultBindingClientService" contract="Server.IClientService"
        name="DefaultBindingClientService">
        <identity>
            <servicePrincipalName value="host/OHS-UPC" />
        </identity>
    </endpoint>
</client>
<bindings>
    <wsDualHttpBinding>
        <binding name="DefaultBindingClientService" />
    </wsDualHttpBinding>
</bindings>

IIS hosted web.config (for ClientService)

<service name="TelPro.OHS.Server.Services.ClientService" behaviorConfiguration="UnsecuredBehavior">
    <endpoint address="" binding="wsDualHttpBinding" bindingConfiguration="DefaultBindingClientService" contract="TelPro.OHS.Server.Services.IClientService"/>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
    <host>
        <baseAddresses>
            <add baseAddress="http://localhost:8020/ClientService"/>
        </baseAddresses>
    </host>
</service>

<wsDualHttpBinding>
    <binding name="DefaultBindingClientService"/>
</wsDualHttpBinding>

<behavior name="UnsecuredBehavior">
    <serviceMetadata httpGetEnabled="true" httpsGetEnabled="false"/>
    <serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>

IIS hosted web.config (for OperatorService -> ClientService)

<client>
    <endpoint address="http://localhost:8020/ClientService" binding="wsDualHttpBinding" 
        bindingConfiguration="DefaultBindingClientService" contract="ClientNotificationServer.IClientService" 
        name="DefaultBindingClientService" />
</client>

<wsDualHttpBinding>
    <binding name="DefaultBindingClientService" />
</wsDualHttpBinding>
SmartK8
  • 2,616
  • 1
  • 29
  • 37
  • If I understand you correctly, OperatorService is also a client of ClientService. Can you show the relevant part of OperatorService's web.config (client endpoint and bindings) in order to compare it to the WPF client? – nodots Jun 13 '16 at 08:03
  • I've added the configuration for OperatorService as a client to ClientService. That was the first place I checked as well, because one is connecting and the other is not. So now I think they're identical, it seem like it is an issue of rights. I can create ClientServiceClient from WPF client to a service (Endpoint/Binding seems correct), but when I call a method it fails. Therefore I'm puzzled. – SmartK8 Jun 13 '16 at 08:15
  • I can connect to a service from WcfTestClient as well (so it's there), unfortunatelly WcfTestClient doesn't allow calling the methods because it doesn't support WsDualHttpBinding. So I can't verify the last step. – SmartK8 Jun 13 '16 at 08:17
  • Just guessing now. What about the servicePrincipalName in the WPF client config, is it correct? I don't know what kind of error would show on an incorrect SPN, so could you change the SPN to something definitely **INcorrect** and see if it's the same "no endpoint listening" error? – nodots Jun 13 '16 at 09:35
  • Oh, and check the config that WCF Test Client generates! It's available in the tree view. – nodots Jun 13 '16 at 09:37
  • I've tried it without SPN before and still the same thing (WcfTestClient contains basically the same config as I do, it also includes the SPN). This is weird like everyone has right to that service except me. I also added netsh http add urlacl url=http://+:8020/ClientService user=Everyone and give rights on a web application to Everyone. I'll try deliberately invalid SPN as you've said. – SmartK8 Jun 13 '16 at 09:42
  • Wrong SPN did the same thing. Able to connect to service (i.e. create client instance), but unable to call a method. – SmartK8 Jun 13 '16 at 09:49

1 Answers1

0

I was able to solve it by switching to port 80.

http://localhost/ClientService

Somehow that works. I've tried to add rules to port 8020 everywhere (even stopped firewall), checked any port forwarding, Azure endpoints, etc. My theory is that the problem when server is trying to connect back (callback) to client and has no rights or something. My guess would be that IIS hosted service doesn't have enough rights to connect back. If anyone can still shed some light on the why, I would gladly switch answer to them. But so far I'm just glad it works regardless the port.

SmartK8
  • 2,616
  • 1
  • 29
  • 37