OK, so you wrote a web service and you may even have tested it and everything worked fine. So the you did some "cleanup" and tried to deploy the web service. It compiles and deploys just fine, but when you try to invoke and hit the service you are presented with the following error:
Server Error in '/' Application.
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.Parser Error Message: Could not create type 'WebServices.Candidates'.Source Error:
Line 1: <%@ WebService Language="C#" CodeBehind="Candidates.asmx.cs" Class="WebServices.Candidates" %>
|
Source File: /Candidates.asmx Line: 1
So just how do you solve this problem?
Here's my checklist of things to check when having trouble deploying web services:
- Check that IIS is using ASP.NET 2.0.
- Begin by starting up the Internet Information Services manager.
- Expand "Web Sites".
- Expand your web site e.g. "Default Web Site".
- Locate the Virtual Directory to which the web service was deployed and right click it.
- On the popup menu, click "Properties".
- On the Properties window, select the "ASP.NET" tab.
- Ensure that the APS.NET Version is set to 2.0.x and not 1.1.x.
- If it is set to 1.1.x, set it to 2.0.x and retry your web service.
- Ensure your Visual Studio build properties are set correctly.
- Locate the .asmx file in your Solution Explorer pane and right click it.
- On the popup menu, click "Properties".
- Ensure that the Build Action is set to "Content".
- Locate the code behind (.cs or .vb) file in the Solution Explorer and right click it.
- On the popup menu, click "Properties".
- Ensure the Build Action is set to "Compile".
- If either of these weren't set correctly, make the correction, recompile, redeploy and retest.
- Ensure ASP.NET 2.0 is an Allowed web services extension.
- Open the IIS Manager.
- Expand your computer.
- Click the "Web Service Extensions" option.
- In the right hand pane, locate the "ASP.NET v2.0.x" entry and ensure that its Status is "Allowed". If it is not allowed, the "Allow" button on the left will be enabled. Click it to change the setting.
- If it was not allowed, correct the setting and retry your service.
- Check for the WebMethod attribute.
- Review your code and ensure that you have the [WebMethod] attribute set for all web methods in the service. This does not mean that all methods have to be web methods, but the ones you are trying to consume should have this attribute in its declaration.
- Ensure the .asmx and code behind file match definitions.
- Open your code behind (.cs or .vb) file.
- Look at the web service declaration at the top.
- In our example, ensure that #2 and #3 match. If they don't, correct the problem.
- Next note the namespace at #1.
- Now open the .asmx file. This can usually be done by double clicking it in the Solution Explorer, but if you're not able to get it to open through the IDE, open Windows Explorer, navigate to the file, right click it and select Open in Visual Studio to work around the problem.
- Now look at the code.
- Note the value of Class in this case is "WebServices.Candidates". The Class value should be the full namespace value as well as the class name. Given our code behind file's values, in this case, the Class value should have been "Crowe.PartnerNomination.WebServices.Candidates", but instead it is just "WebServices.Candidates". This is a common issue when reworking already written web services into a namespace hierarchy. For some reason the .asmx file does not always reflect the changes made which then causes the error message at the beginning of this post.
- Change the Class value, recompile, redeploy and retest.
Later
C
C
No comments:
Post a Comment
Comments are moderated only for the purpose of keeping pesky spammers at bay.