Reputation: 6868
I have created 1 demo web application in which i am trying to consume wcf service which contains no svc file.Basically i am trying to add routes to routetable like we add in asp.net mvc.
I have taken reference from here :Reference
Code :
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class PersonService : IPersonService
{
[WebInvoke(UriTemplate = "", Method = "GET")]
public void GetPerson()
{
string k = "a";
}
}
[ServiceContract]
public interface IPersonService
{
[OperationContract]
void GetPerson();
}
public class Global : System.Web.HttpApplication
{
protected void Application_Start(object sender, EventArgs e)
{
RouteTable.Routes.Add(new ServiceRoute("foo", new WebServiceHostFactory(), typeof(PersonService)));
}
}
Web.config :
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
<standardEndpoints>
<webHttpEndpoint>
<standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true"/>
</webHttpEndpoint>
</standardEndpoints>
</system.serviceModel>
when i try to call my GetPerson method from browser then i am getting EndPoint not found.
Can anybody please help me with this?
Upvotes: 0
Views: 428
Reputation: 6868
Ok i manage to solve it by providing name of my method in Uritemplate like below :
[WebInvoke(UriTemplate = "GetPerson", Method = "GET")]
public void GetPerson()
{
string k = "a";
}
Upvotes: 0