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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

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.

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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

626 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