How to access IIS-hosted WCF Web service from IIS app

Posted on 2015-02-15
Last Modified: 2015-02-15
I have a web service running on IIS that works well when I access it from an app running on my local machine. However when I try to run that same app from the IIS machine, the web service part of the app fails.

I've looked at firewall issues w/o success. I'm having no luck getting any debug messages to see where it fails.  Could be the endpoint addressing, since the consuming client and the service are both running as different addresses on the same IIS host.

I am trying to avoid using localhost in the client app b/c the client app is meant to be a sample that others will study, to implement their own clients against my service.
Question by:Mark Klein
  • 4
  • 4
LVL 30

Expert Comment

by:Alexandre Simões
ID: 40610809
What is the error?

Author Comment

by:Mark Klein
ID: 40610894
Thanks for responding.  Error is
Server Error in '/' Application.
Details are not helpful:
Runtime Error

Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.

Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".

<!-- Web.Config Configuration File -->

        <customErrors mode="Off"/>

Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL.

<!-- Web.Config Configuration File -->

        <customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
I've tried the second of these, can't find the file

Author Comment

by:Mark Klein
ID: 40610923
to aid debug, I've just added
 <serviceDebug includeExceptionDetailInFaults="true"/>

to web.config, but it doesn't give me any more info.
I'm now trying to access the web service from a browser
LVL 30

Expert Comment

by:Alexandre Simões
ID: 40610944
Try and set the CustomErrors off like it says in the error message.
This should give you a better understanding of what's going on.

To do so, go to your web.config, search for the customErrors element and set it as:
        <customErrors mode="Off"/>

Open in new window

Run the application again and tell me what's the error now.
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.


Author Comment

by:Mark Klein
ID: 40611033
Here's the error report--unable to connect to service, it seems
Server Error in '/' Application.

A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[SocketException (0x274c): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond]
   System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) +273
   System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception) +584

[WebException: Unable to connect to the remote server]
   System.Net.HttpWebRequest.GetRequestStream(TransportContext& context) +1176
   System.Net.HttpWebRequest.GetRequestStream() +23
   System.ServiceModel.Channels.WebRequestHttpOutput.GetOutputStream() +187

[EndpointNotFoundException: There was no endpoint listening at that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.]
   System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +14483202
   System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +622
   TestDBAccess.Arrows9WS.IService1.GetTopCrossSells(String customerId, String ProductCategory) +0
   TestDBAccess.Arrows9WS.Service1Client.GetTopCrossSells(String customerId, String ProductCategory) in \\psf\home\Documents\Visual Studio 2013\Projects\TestDBAccess\TestDBAccess\Service References\Arrows9WS\Reference.vb:450
   TestDBAccess.CallCenterSample.btnGrooming_Click(Object sender, EventArgs e) in \\psf\home\Documents\Visual Studio 2013\Projects\TestDBAccess\TestDBAccess\CallCenterSample.aspx.vb:82
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +155
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3804
no endpoint listening.  You can run this yourself; I hacked up a testbed at
Once there, ignore the default home page, click on the About menu where I've put a couple of buttons to my test code.  Use the call center app button; select a customer, and then click a button.  As you can see from the trace, I clicked the btnGrooming.

Now when I run this code from VS on my local machine, it works perfectly, but my local is not on the same box or domain as the testsite app.

You can see the service by going to
The wsdl file is reachable by selecting service1.svc from the resultant directory
LVL 30

Accepted Solution

Alexandre Simões earned 500 total points
ID: 40611051
Ok, so you have a configuration issue there.
The problem is that the application is not able to reach the service.

From the error message I see that you're pointing towards:
which doesn't respond.

I went in and saw that you actually have that service there but not through that port.
So I just removed the port from that URL and it works:

Just fix the URL in your web.config and everything should work just fine, but from inside and outside the server.

Just as a side note (and word of advise), disable directory listing on your IIS.
Going to anyone can see your server contents.


Author Closing Comment

by:Mark Klein
ID: 40611114
Prompt, precise advice.  appreciated.

Alexandre, I removed the virtual directory reference from the web.config endpoint, and yes, it immediately worked.  I had it there b/c w/o that :15024 I was not able to see the directory when I browsed, so I figured it was necessary.  I appreciate your advice about disabling the directory listing, which I had on to help me know the service was alive.

In the services/host section of the servicemodel in the web.config of the service itself, that port address is also present.  Should I remove it there too? I do have the 15024 port open both ways on the firewall, and I have the service itself with a binding to that port.

Sorry for the delayed response time on my end.  I live in coastal NH in USA, and we've been blanketed w snow over the past few weeks, up to my chest in the yard.  I've been going between computing and shoveling.
LVL 30

Expert Comment

by:Alexandre Simões
ID: 40611316
Yes, you should take the port out of the service web.config.
As far as I understood here, your IIS and DNS configs don't take that port in consideration in any way.

Probably you had that while developing in Visual Studio directly on IIS Express instead of the proper IIS? (this is my hunch)

And by the way, that thing with the snow is a pain.
I'm in Switzerland but it haven't been snowing that much around here.
Good luck mate!

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
IIS 7 Log 2 19
IIS8 Internal IP Address Disclosed in HTTP Headers 21 33
ASP.NET reading ATOM 2 26
Re-position the objects 7 50
Debug Tools to analyse IIS process: This article focus on taking memory dumps from IIS to determine which code is taking more time and to analyse which calls hangs/causes more CPU usage. To take dumps,download the following. Install1: To st…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video discusses moving either the default database or any database to a new volume.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now