If you use a Windows server to host IIS, and you installed IIS as an additional feature after Windows was already installed for a while, its likely that if you try to use the SQL Server 2008 R2 or SQL Server “Denali” Master Data Services web service it will fail to work.
Why? Order of operations matters, because MDS relies on Windows Communication Foundation technology (WCF) and if you install IIS after the WCF pieces were installed, then WCF doesn’t know to register itself into IIS list of handlers. What is WCF? Read here if you are curious… http://msdn.microsoft.com/en-us/library/ms731082.aspx
The MDS Configuration Manager installed the website, and the service, but it did not check if the service actually functions! darn.
This is the error I get when I visit the MDS’s web service in my browser at the website URL, something like http://localhost:80/Service/Service.svc
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.
This error usually indicates that the *.svc Handler is not installed.
1. To check this, look in your IIS Manager (this happens to be IIS 7.5 from Windows 7).
2. Click on the Server name (the top most node in the Connections tree on the left)
3. Click on Handler Mappings icon under the IIS category in the middle Features View pane
4. Notice there is no *.svc handler mentioned. I sorted by Path column to make it easier to spot that. R’s then S’s but no *.svc…
I found the common solution is documented here.
If you installed IIS after Windows Communication Foundation (WCF) was installed you must run the following command.
"%WINDIR%\Microsoft.Net\Framework\v3.0\Windows Communication Foundation\ServiceModelReg.exe" -r
This registers the required script maps in IIS so it can run WCF based web services. You must also make sure that the .svc file type is mapped to aspnet_isapi.dll.
We did the 64-bit one because my server was 64-bit.
"%WINDIR%\Microsoft.Net\Framework64\v3.0\Windows Communication Foundation\ServiceModelReg.exe" -r
1. To run it, start an elevated Command prompt. Start > cmd
2. Had to confirm Y (Yes) I will accept this risk that it may damage something that’s already working with WCF technology.
3. It ran for a minute, and then returned to the prompt…
4. Now I revisit the Handler Mappings in IIS manager. Notice that *.svc is a supported handler now. F5 to refresh the list I think.
5. Double Click on the svc-Integrated item. It will hang for a second, then finally open to show this kind of thing…
It points to .Net 3.0 on my box, which is what I expect because I ran the installer for WCF from .Net 3.0 version "%WINDIR%\Microsoft.Net\Framework64\v3.0
System.ServiceModel.Activation.HttpHandler, System.ServiceModel, Version=18.104.22.168, Culture=neutral, PublicKeyToken=b77a5c561934e089
Now I test my MDS Web service again via the browser, and it works. Well, it gives a warning about Metadata being disabled, but that’s normal. “Metadata publishing for this service is currently disabled.” That’s the default behavior, but at least the service seems alive now, with no 404 or 403 errors.
Show the Metadata if you want to develop against this Service
I like to get rid of this warning, for development purposes you would need to see the metadata presented by the Web Service to write you code against.
If its a production server, you probably don’t need to do anything, because exposing metadata is unnecessary if the client application is already written.
1. Since my Program Files folder is protected by UAC in this version of Windows, I run Notepad as elevated Administrator.
2. In Notepad, open the web.config file that lives underneath the virtual directory used for MDS. By default that is something like C:\Program Files\Microsoft SQL Server\Master Data Services\WebApplication then point to web.config (show all files *.* to see it in the browse dialogue)
3. Control+F to Find the tag <serviceMetadata
Set one of the options to true, depending on if you are using http or https for your website/service.
httpGetEnabled="true" or httpsGetEnabled="false"
I just did the httpGetEnabled, since I only am using http on my machine.
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="false"/>
4. Save the change.
5. Refresh your browser pointed at your web service URL http://localhost:8080/Service/Service.svc
Note it gives you a test command line to try now…
6. Run a test of your web service to make sure it functions. Open an elevated command prompt again or you will get access denied to your .cs and .tmp files because program files is locked down tightly.
cd C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\ svcutil.exe http://localhost:8080/Service/Services.svc?wsdl
SvcUtil is explained here http://msdn.microsoft.com/en-us/library/aa347733.aspx
It lives in an SDK folder, such as
C:\Program Files\Microsoft SDKs\Windows\v6.0\Bin
C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin
7. Check the output if you are curious. Output defaults to the same folder where the svcutil.exe was called from, or you can do /out to redirect it to another file location.
C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin
8. I didn’t go as far as to code a sample app to talk to this web service, but I’ll save that for another day. Here a nice blog to get you started using your working web service.