Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Methods in Web Service in VS2010 Framework 3.5 not showing up when ran locally

I am trying to create a web service in VS2010 and doing it as a 3.5 Framework Web Service project.

I have the default Hello World method in there and some that I have added. The ones I have added have a call to a data provider class that in turn connects to the dataset. However when I run locally I only see the Hello World method and not my new methods. I then delete the hello world method and rerun and I still see it.

What do I need to do to run this locally and is it the same process as to have it run on my staging and production servers?

I am used to creating services in 1.1 and this is my first one I am creating in 3.5.

like image 535
aaarneson Avatar asked Dec 28 '12 17:12

aaarneson


1 Answers

I'm assuming that by "It's not showing up" you mean that when you run the web services website and navigate to the .asmx page the method isn't showing up in the list of available service calls as shown in this screenshot:

enter image description here

IF that's what you mean....

Most likely you're either missing the [WebMethod()] declaration just before the function definition, or the method is not declared as public.

Example:

[WebMethod()]
public string GetName(int EmployeeNumber)
{
   // some code to get name from emplyee #
   return ReturnValue;
}

should show up when you run the web service project locally.

Neither of these would:

public string GetName(int EmployeeNumber)
{
   // some code to get name from employee #
   return ReturnValue;
}

or

[WebMethod()]
private string GetName(int EmployeeNumber)
{
   // some code to get name from employee #
   return ReturnValue;
}

Further, I'm guessing that the reason that you see your method when you delete the HelloWorld method, the reason is that you are deleting just the method and leaving the [WebMethod()] declaration. This would then change the code so that the [WebMethod()] declaration is being applied to your function, as it's probably the first function after the declaration.

like image 143
David Avatar answered Sep 21 '22 04:09

David