4thSpace
4thSpace

Reputation: 44312

How to expose WCF method?

I'd like to access a WCF method via url. For example:

localhost:8080/TestService.svc/MyMethod

When I do the above, I get a webpage cannot be found. In the Interface file, I have added the following above MyMethod.

[WebGet]  
[OperationContract]  
void MyMethod();

but that didn't change anything. Any ideas?

Upvotes: 0

Views: 1385

Answers (4)

Brad Ruderman
Brad Ruderman

Reputation: 2173

I think the quickest solution is to use a factory. It seems likely they would want a restful service so if you follow this guide you wont even need to specify anything in the web.config. See the first answer on this question.

Bare Minimum Configuration for RESTful WCF

Upvotes: 0

parapura rajkumar
parapura rajkumar

Reputation: 24403

Here is a nice example on how to achieve this

Upvotes: 0

sharp_net
sharp_net

Reputation: 737

How does your web.config look like? Are you using REST?

Have you looked at below post? Making a WCF Web Service work with GET requests

Upvotes: 1

Lews Therin
Lews Therin

Reputation: 10995

I don't think you can. You need to use REST to do what you want. Or use a Controller/Action (if this is MVC) that will create a proxy object to consume the service e.g.

ServiceClient client = new ServiceClient();
client.MyMethod()

Upvotes: 0

Related Questions