tags:

views:

89

answers:

3

On a production server (Windows Server 2003 SP2) I can connect to a remote WCF service with Internet Explorer 8: When I browse to the URL http://www.domain.com/Service.svc (where my service listens) I get the expected info page of the service displayed. Connection settings in Internet Explorer only specify "auto detect", proxy settings are disabled.

If I start a console application (built with WCF in .NET 4.0) on the same server which also tries to connect to the same WCF service it fails telling me that no endpoint was available listening on http://www.domain.com/Service.svc.

Configuration of the WCF client:

<configuration>
  <system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="WSHttpBinding_IMyService" closeTimeout="00:01:00"
            openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
            bypassProxyOnLocal="false" transactionFlow="false"
            hostNameComparisonMode="StrongWildcard"
            maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
            messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
            allowCookies="false">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" 
              maxArrayLength="16384"
              maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <reliableSession ordered="true" inactivityTimeout="00:10:00"
              enabled="false" />
          <security mode="None">
            <transport clientCredentialType="Windows" proxyCredentialType="None"
                realm="" />
            <message clientCredentialType="Windows" negotiateServiceCredential="true"/>
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://www.domain.com/Service.svc"
          binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IMyService"
          contract="Service.IMyService" name="WSHttpBinding_IMyService" />
    </client>
  </system.serviceModel>
<configuration>

With these settings I can communicate successfully with the remote service from my development machine.

Looking around for other options I found that I can specify to use the Internet Explorer proxy settings with:

<system.net>
  <defaultProxy>
    <proxy usesystemdefault="true" />
  </defaultProxy>
</system.net>

It didn't work and I am not sure if I understood this setting really correctly. (My hope was that the WCF client will adopt the "autodetect" setting of Internet Explorer and then connect the same way to the service like the installed IE.)

I also had toggled the useDefaultWebProxy setting in the binding configuration between true and false with no success.

Now I am asking for help what I can do? Which settings might be wrong or missing? What could I test and how can I get more detailed error messages to better identify the problem?

Thank you in advance!

Edit:

Stack in Innerexception is saying:

  • System.Net.WebException: Connection to remote server could not be established
  • System.Net.Sockets.SocketException: Connection failed since the host didn't answer after a certain time span or the connection was faulted since the connected host didn't answer.
A: 

I am not sure how you are hosting your service, IIS?

I didn't see anything wrong really in the configuration, other than

  <security mode="None">
    <transport clientCredentialType="Windows" proxyCredentialType="None"
        realm="" />
    <message clientCredentialType="Windows" negotiateServiceCredential="true"/>
  </security>

If you say that when you type in the address in the IE you see the service, then it is leading me to believe that it is security setting that are wrong. Try removing the security block form the client config file or where ever you have it and see if that works....

If it does, we might have it narrowed it down...

VoodooChild
I've removed that block but it didn't help. Security mode is set on both sides - service and client - to "None". The service is hosted in IIS 7.0 on a Windows Server 2008, if that matters. What is confusing me is that it works from my delevopment computer but not from the production machine - with the same config.
Slauma
is this the actual endpoint "address="http://www.domain.com/Service.scv" or are you using "localhost" on a dev machine somewhere?
VoodooChild
No I am testing against a "live" service - also on my dev machine. So the address of the service is really exactly the same in both configs, on my dev client and on the production client. (see also my comment to marc_s's answer)
Slauma
A: 
marc_s
Ah, sorry, it was written wrong in my question. It is actually `svc` (I've changed it know in my question). I was guessing the same (that I could have written something wrong when moving from dev to production machine), especially since it was deep in the night and I only saw a soup of rotating config tags in front of my eyes. To make sure the address is correct I had copied and pasted it then from dev to production config files. So finally: The address in the dev config is definitely the same as in the production config.
Slauma
Yes, the svc file is really in the root of the IIS site. It seems to work (from my dev machine). But is that bad practice (in terms of security, may be?)? Should it be better in a subfolder? The svc-file has only one line with a "page directive" like `<%@ ServiceHost Service="MyServiceLib.MyService" %> and the service itself is in a separate DLL assembly in the Bin folder.
Slauma
just to make sure, your service is in "..\Inetpub\wwwroot\ServiceDirectory" ???
VoodooChild
@VoodooChild: No, actually my physical location of the site is even on another hard drive, something like d:\MySiteFolder\Service.svc. But it is mapped as a virtual directory in IIS. But anyway: The connection issue is solved, see my own answer.
Slauma
+1  A: 

Although Internet Explorer can connect to the service without specifying a proxy address but only enabling the "auto detect" feature this doesn't seem to work with my WCF client when setting <proxy usesystemdefault="true" />. (Documentation says: This will pickup the Internet Explorer settings. But it doesn't work.) Finally the customer gave me a concrete proxy address and I have changed the binding in my client configuration the following way:

  • Changed: useDefaultWebProxy="false" (instead of true)
  • Added: proxyAddress="http://10.20.30.40:8080" (Edit2: Not only IP-address! The prefix with http:// is important! Otherwise it will throw new exceptions, see the follow-up question below.)

With this the WebException and SocketConnection disappeared and the Client seems to connect to the Service but I am having now the next issue when calling the first service operation. I will put this in an new question.

Edit: Here is the follow-up question:

http://stackoverflow.com/questions/3048240/strange-exception-when-connecting-to-a-wcf-service-via-a-proxy-server

Edit2: According to the answer in the follow-up question it is important to prefix the proxyAddress with http. (changed my answer now)

Slauma