Solved

Hosting webservice in IIS

Posted on 2011-03-15
20
1,372 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
 

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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Prologue It is often required to host multiple websites on a single instance of IIS, mostly in development environments instead of on production servers. I am sure it is not much a preferred solution on production servers but this is at least a pos…
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

706 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

20 Experts available now in Live!

Get 1:1 Help Now