Solved

WCF newbie, method not exposed.

Posted on 2010-08-23
4
403 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 500 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

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

688 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