How to access IIS-hosted WCF Web service from IIS asp.net app

Posted on 2015-02-15
Medium Priority
Last Modified: 2015-02-15
I have a web service running on IIS that works well when I access it from an asp.net 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 31

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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

LVL 31

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 http://arrowswebservice.loyaltybuilders.com:15024/Service1.svc 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 31

Accepted Solution

Alexandre Simões earned 2000 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 http://arrowswebservice.loyaltybuilders.com 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 31

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

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

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…
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
In this video I will demonstrate how to set up Nine, which I now consider the best alternative email app to Touchdown.
If you are looking for an automated tool which can generate reports for Outlook emails and other items from PST file, then you can go for Kernel PST Reporter tool. The reports which are created by this tool are helpful to analyze and understand PST …

589 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