Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

WCF newbie, method not exposed.

Posted on 2010-08-23
4
Medium Priority
?
405 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

What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

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…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

636 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