Link to home
Start Free TrialLog in
Avatar of MeritorWabco
MeritorWabco

asked on

Hosting webservice in IIS

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!
User generated image
Avatar of Randy Downs
Randy Downs
Flag of United States of America image

You may have permissions problems. The easiest way to get the permissions right is to copy your site to the default web in inetpub.
Avatar of MeritorWabco
MeritorWabco

ASKER

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
yeah that's the right folder. Try opening a simple html page or just localhost
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?

 User generated image
Here is what I see when I open my service in browser from my project using ASP.NET development server.

 User generated image
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.
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.
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.
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.
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/
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. '

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.  
ASKER CERTIFIED SOLUTION
Avatar of Randy Downs
Randy Downs
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
awesome. Glad you got it.
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" />
That seems to be a different issue I appreciate your help with my IIS not being configured correctly.
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
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.