Solved

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

Posted on 2015-02-15
8
373 Views
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.
0
Comment
Question by:Mark Klein
  • 4
  • 4
8 Comments
 
LVL 30

Expert Comment

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

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 -->

<configuration>
    <system.web>
        <customErrors mode="Off"/>
    </system.web>
</configuration>

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 -->

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

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
0
 
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:
<configuration>
    <system.web>
        <customErrors mode="Off"/>
    </system.web>
</configuration>

Open in new window

Run the application again and tell me what's the error now.
0
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 54.86.149.183:15024

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 54.86.149.183:15024

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 54.86.149.183:15024]
   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
http://testsite.loyaltybuilders.com
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
http:arrowswebservice.loyaltybuilders.com:15024
The wsdl file is reachable by selecting service1.svc from the resultant directory
0
 
LVL 30

Accepted Solution

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

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.

Cheers!
0
 

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.
0
 
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!
0

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 (http://www.enterprise.efax.com), 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