开发者

Hosting WCF web services on IIS - works in VS, but not in IIS

开发者 https://www.devze.com 2022-12-18 19:51 出处:网络
I\'m very new in web programming stuff, so my question is about basics. I\'m developing a SilverLight application and need to access the database from it. I\'m using LINQ to SQL to get data from datab

I'm very new in web programming stuff, so my question is about basics. I'm developing a SilverLight application and need to access the database from it. I'm using LINQ to SQL to get data from database and a WFC web service to deliver it to my app.

Everything is working fine when I'm running my app within Visual Studio. When trying to publish the web service to IIS - the web service call fails.

To make my question simple, I will focus on a brand new web service. Here the steps I'm doing:

  1. Start Visual Studio 2008 -> File -> New -> Project -> Web -> WCF Service Applicat开发者_如何学编程ion Project Name: MyWcfService

  2. Resulting Visual Studio generates a sample project with implemented Web Service "Service1"

  3. Rebuild, start from Visual Studio (host on ASP.NET Development server) --> Everything works fine, I see my service under http://localhost:52489/Service1.svc link

  4. Now I want to host this service on my IIS (I've IIS7 on Vista x86 PC) Visual Studio -> right click Project -> Publish -> target location -> Create new web app named "MyWcfService" -> Publish

  5. Just to be sure check my C:\inetpub\wwwroot\ folder - now it contains the "MyWcfService" subdirectory with all required files.

  6. Open IE on my PC http://localhost/MyWcfService/Service1.svc

The result is:

HTTP Error 404.3 - Not Found The page you are requesting cannot be served because of the extension configuration. If > the page is a script, add a handler. If the file should be downloaded, add a MIME map.

I were trying to remove "identity" section from web.config - same problem. Switching off the firewall does not help either.

Can anyone help me? What I'm doing wrong? Maybe I am missing something?


Per Nicholas Allen, Program Manager WCF/WWF,Silverlight @ Microsoft:

What registration in IIS is responsible for processing SVC files?
There are two parts to the registration. One part is related to ASP.NET and the other part is related to WCF. The ASP.NET part is that the ASP.NET ISAPI has to be a service extension for IIS. The WCF part is that the HTTP handler has to be a managed handler.

The commands for setting up the two parts are "aspnet_regiis –i –enable" from the 2.0 framework tools and "ServiceModelReg.exe -r" from the 3.0 framework tools.

This results in a managed handler "System.ServiceModel.Activation.HttpHandler, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" and an ISAPI module "%SystemRoot%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" for *.svc files in IIS. In the IIS handler mappings, the managed handler has to be above the ISAPI module for this to work.

Together, the two parts start an HTTP pipeline and pass the resulting requests into WCF.


IIS will only direct requests to ASP .NET for certain files like aspx by default. I'm guessing that you don't have the svc extension mapped to asp .net. Try looking at this http://msdn.microsoft.com/en-us/library/bb515343.aspx.


Silverlight can only call web sevices in the exact same domain as the application (where the xap file lives)

To call a different domain you need to have a clientaccesspolicy.xml file where the web service lives. It's possible this is your problem.

<?xml version="1.0" encoding="utf-8" ?>
<access-policy>
      <cross-domain-access>
            <policy>
                  <allow-from>
                        <domain uri="*" />
                  </allow-from>
                  <grant-to>
                        <resource path="/" include-subpaths="true" />
                  </grant-to>
            </policy>
      </cross-domain-access>
</access-policy>


You might not have ASP.Net setup properly in IIS. Take a look at this article:

http://msdn.microsoft.com/en-us/library/aa964620.aspx

0

精彩评论

暂无评论...
验证码 换一张
取 消