Solved

WCF newbie, method not exposed.

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
error on the asp.net page 1 33
Problem to error 4 44
How to Decrypt in C# a string that is encrypted with Coldfusion Encrypt(string, seed) function 11 73
Error in script 11 46
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…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

911 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

23 Experts available now in Live!

Get 1:1 Help Now