Solved

Hosting webservice in IIS

Posted on 2011-03-15
20
1,378 Views
Last Modified: 2012-06-21
I am very new to WCF services and hosting anything in IIS. So take baby steps with me :).

I created a WCF service library and configured the end points using app.config.  I was able to test the service by hosting in WcfSvcHost and testing with WcfTestClient.

I then added a new web site application, ASP.NET web service, to my project and added a reference to my service library and configured my .svc file to point to my service library. Configured my end points by copying my app.config file into my project and renaming to web.config. I was able to host this by viewing in the broswer with ASP.NET development server.  I tested with WcfTestClient and it worked fine.

Now to my problem....

Then I wanted to host my web application in IIS.  So I added my web application to my default web site in IIS.  I pointed the physical path to my application directory and then verified that my .svc file and libraries were added correctly.  But when I tried to view my .svc in browser I got a 'HTTP 500 Internal Error'.  Why??? And how do I fix it??

Thanks!
Screen shot of IIS
0
Comment
Question by:MeritorWabco
  • 11
  • 9
20 Comments
 
LVL 29

Expert Comment

by:Randy Downs
ID: 35138526
You may have permissions problems. The easiest way to get the permissions right is to copy your site to the default web in inetpub.
0
 

Author Comment

by:MeritorWabco
ID: 35138762
I moved my folder that contains my application to the inetpub/wwwroot directory.  Is that what you mean??


I was able to open the .svc file in browser but it just opened up as a blank page. Do you know why that would happen?  Could it be that I am not exposing my meta data correctly?  See my attached Web.config.
blank-page.png
Web.config
0
 
LVL 29

Expert Comment

by:Randy Downs
ID: 35138861
yeah that's the right folder. Try opening a simple html page or just localhost
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:MeritorWabco
ID: 35138969
Not sure what you mean.  Are you wanting me to add an html page to my project? And then open that with the browser?  Or just right click the default web site and view in browser?  Like the image I attached?

 screen shot
0
 

Author Comment

by:MeritorWabco
ID: 35139044
Here is what I see when I open my service in browser from my project using ASP.NET development server.

 Screen shot
0
 
LVL 29

Expert Comment

by:Randy Downs
ID: 35139056
I'd just like to see something besides a blank page. Just add some text to a index.html & call it directly localhost/index.html. I suspect that it will work fine.
0
 
LVL 29

Expert Comment

by:Randy Downs
ID: 35139107
I can't read your development server page very well but I'd try adding the suggested code & see what happens on the development server.
0
 

Author Comment

by:MeritorWabco
ID: 35139226
You might have to download the images to see them.

In regards to viewing I don't know exactly what you mean.  Sorry I am new to html and web development.  But I added an HTML page to my project called Index.htm.  I was able to view the text in my development server but when I moved everything to the wwwroot directory to view it from IIS it still came up as a blank page when i tried to view index.htm in browser.
0
 

Author Comment

by:MeritorWabco
ID: 35139320
I just tried to open the iisstart.htm file in wwwroot from IIS (http://localhost/iisstart.htm) it came up blank also.  But when i open the file directly (C:\inetpub\wwwroot\iisstart.htm) it opens fine.
0
 
LVL 29

Expert Comment

by:Randy Downs
ID: 35139335
OK it sounds like your localhost is not setup properly. Try this - http://learn.iis.net/page.aspx/28/installing-iis-7-on-windows-vista-and-windows-7/
0
 

Author Comment

by:MeritorWabco
ID: 35139635
Hey we made progress. I am open to open the html page and the local host.  

I got some errors that forced me to install some modules that I didn't install using the guide you had provided.  

The first error I got was HTTP Error 404.3 - Not Found. So i performed the following.
I ran ServiceModelReg -i from the command prompt from directory  "c:\windows\Microsoft.Net\Framework\v3.0\Windows Communication Foundation\"

I tried it again and then I got HTTP Error 500.21 - Internal Server Error.  So I performed the following.
I ran aspnet_regiis.exe -i in VS 2010 command prompt.

Of course now when I open it I get another error.
'The type 'TestServiceLibrary.TestService', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found. '

0
 

Author Comment

by:MeritorWabco
ID: 35139667
I had to right right click the default web site node and select add application.  I had to point the physical path to my folder in wwwroot and now it opens up fine.  
0
 
LVL 29

Accepted Solution

by:
Randy Downs earned 500 total points
ID: 35139703
0
 
LVL 29

Expert Comment

by:Randy Downs
ID: 35139713
awesome. Glad you got it.
0
 

Author Comment

by:MeritorWabco
ID: 35139737
Of course it opens in the browser but when I try to access it from WcfTestClient using 'http://localhost/TestSite/test.svc'  it doesn't work. I get the following error from WcfTestClient when trying to add the service 'Failed to add a service. Service metadata may not be accessible. Make sure your service is running and exposing metadata.'

I must not be exposing my metadata end point correctly or accessing it correctly.

In my web.config i have my metadata endpoint defined as the following:
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
0
 

Author Closing Comment

by:MeritorWabco
ID: 35139752
That seems to be a different issue I appreciate your help with my IIS not being configured correctly.
0
 

Author Comment

by:MeritorWabco
ID: 35148652
I am not sure if you are familiar with working with WCF or not but I still haven't been able to figure out my error I am facing.  500pt question if you can help. http://rdsrc.us/7VNt9o
0
 
LVL 29

Expert Comment

by:Randy Downs
ID: 35149368
0
 

Author Comment

by:MeritorWabco
ID: 35149467
I have pretty much the exact same thing in that site for exposing the metadata endpoint along with the service behavior and I can l view the .svc file in the browser fine and expose the end points using the metadata in WcfTestClient.  The problem is when I hose my service in IIS instead of the ASP.NET development server I get an error when I try to connect to my service using WcfTestclient.
0
 
LVL 29

Expert Comment

by:Randy Downs
ID: 35149647
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Today I came across an interesting issue that had me pulling my hair out.  I was troubleshooting a new internal web site which uses integrated security instead of anonymous.  When browsing the site from my laptop, I was able to access it with no iss…
This tutorial will show you how to add an attribute to an XML (http://en.wikipedia.org/wiki/XML) stream returned from a Windows Communication Foundation (http://en.wikipedia.org/wiki/Windows_Communication_Foundation) (WCF) Web Service.  Some knowled…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

813 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

18 Experts available now in Live!

Get 1:1 Help Now