• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 252
  • Last Modified:

Error while setting reference to web service

Hi,

I am using .NET 2005 Team Architect Edition. I created new project of type web service. This has default one webmethod Hello. I did not make any change. I "Build" the web service. Then I published it.

Then I opened a new web application. Now when I try to set Web Reference to this web service, I get following error:

Server Error in '/Sample' 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 'Forex.Service1'.

Source Error:

Line 1:  <%@ WebService Language="C#" CodeBehind="Service1.asmx.cs" Class="Forex.Service1" %>

Source File: c:\inetpub\wwwroot\Sample\Service1.asmx    Line: 1
 
Regards
mi
0
vj_mi
Asked:
vj_mi
  • 2
  • 2
1 Solution
 
tuttlepcCommented:
have you ever programmed a web service before?
0
 
tuttlepcCommented:
my main questions are: what is the purpose of your web service... are you pulling from a db... and expecting to use the results and... do something with it

or....

execute a webservice and have it to something on the originating server?...

and there's others... but .. i need all your source to help further
0
 
vj_miAuthor Commented:
Hi tuttlepc,

Well... at the moment I am returning hardcoded value from the web method. See attached code.

Regards,
MI
using System;
using System.Data;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.ComponentModel;
 
namespace Session_WebService_Create
{
    /// <summary>
    /// Summary description for Forex
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [ToolboxItem(false)]
    public class Forex : System.Web.Services.WebService
    {
 
        [WebMethod]
        public Single USDollarToINR(Single dollar)
        {
            return (Single)(dollar * 38.39);
        }
 
        public Single BritishPoundToINR(Single bPounds)
        {
            return (Single)(bPounds * 89.00);
        }
 
        public Single EuroToINR(Single euros)
        {
            return (Single)(euros * 58.25);
        }
    }
}

Open in new window

0
 
Syed Irtaza AliLead Software ArchitectCommented:
Replace the code with the following
All I have done is removed the namespace tag and added [WebMethod] to all methods.
using System;
using System.Data;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.ComponentModel;
 
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
public class Forex : System.Web.Services.WebService
{
    [WebMethod]
    public Single USDollarToINR(Single dollar)
    {
        return (Single)(dollar * 38.39);
    }
 
    [WebMethod]
    public Single BritishPoundToINR(Single bPounds)
    {
        return (Single)(bPounds * 89.00);
    }
 
    [WebMethod]
    public Single EuroToINR(Single euros)
    {
        return (Single)(euros * 58.25);
    }
}

Open in new window

0
 
Syed Irtaza AliLead Software ArchitectCommented:
And replace the following line
 <%@ WebService Language="C#" CodeBehind="Service1.asmx.cs" Class="Forex.Service1" %>

to this

 <%@ WebService Language="C#" CodeBehind="Service1.asmx.cs" Class="Forex" %>

since the class name you are using is Forex and not Forex.Service1
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now