?
Solved

WCF newbie, method not exposed.

Posted on 2010-08-23
4
Medium Priority
?
404 Views
Last Modified: 2012-06-27
Hi

I'm learning WCF. I have a class HelloWorldService.cs hosted by ASP.NET Dev Server and have created an interface for this. I consume the Service using a console app. Works fine with the first "Hello World" method GetMessage, however when I add a second method AddTwoNames, it just refuses to appear anywhere. Tried updating the Service Reference, removing it, even rebooting. Where am I going wrong please?

Thanks.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MyWCFServices
{
	public class HelloWorldService: IHelloWorldService
	{
		public string GetMessage(string name)
		{
			return "Hello from " + name + "!";
		}
		public string AddTwoNames(string firstname, string lastname)
		{
			string fullname = string.Empty;
			fullname = firstname + " " + lastname;
			fullname.ToUpper();
			return fullname;
		}

	}
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;

namespace MyWCFServices
{
	[ServiceContract]
	public interface IHelloWorldService
	{
		[OperationContract]
		string GetMessage(string name);
		string AddTwoNames(string firstname, string lastname);
	}
}

Open in new window

0
Comment
Question by:jonatec
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 11

Expert Comment

by:PlatoConsultant
ID: 33500520
just clean the solution from gui menu, or delete all files from the bin directory. and then update the reference.
0
 
LVL 19

Expert Comment

by:daveamour
ID: 33500615
Also fullname.ToUpper() won't work.
You need to put fullName = fullname.ToUpper()


0
 

Author Comment

by:jonatec
ID: 33500681
Tried solution Clean and re-build, second method still doesn't appear the object browser for the Service Reference, (please see screen shot).


dump-1.jpg
0
 
LVL 1

Accepted Solution

by:
luisx25 earned 2000 total points
ID: 33513135
You need to add the tag [OperationContract] to thje second method. Like this:

            [OperationContract]
            string GetMessage(string name);
                                           [OperationContract]
            string AddTwoNames(string firstname, string lastname);
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question