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
vj_miAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.