Solved

WCF newbie, method not exposed.

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Here I am going to explain creating proxies at runtime for WCF Service. So basically we use to generate proxies using Add Service Reference and then giving the Url of the WCF service then generate proxy files at client side. Ok, what if something ge…
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now