Click here to Skip to main content
14,695,617 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Guys,

I am trying to create a wcf service which will work as a web and windows service both.
Actually, I have created the wcf service in which I included the installer. And it works fine.
But to call a wcf service method, I need to add a service reference in my application.
But I need to call the wcf service methods using the links through jquery, not by referring the service object.
And also wants to enable the cross domain ajax call to make GET and POST requests.

Can anybody has some solution for this.

Thanks in advance.
Posted
Updated 20-Oct-20 0:00am
v3

There are several ways to do this. you can create a WCF service and make one windows service which will use that webservice. see this link .

there are four ways to deploy the WCF service
1) Hosted in IIS,
2) WAS(windows activation service)
3)Self hosting
4)Windows services

you can see this link I found in deference between web service and WCF services

Hope this helps
   
Comments
leonidasvijay 20-Jun-14 1:11am
   
Thanks for replying.

Main issues I am getting before hosting the wcf service as a window services are :

(1) When I call the methods defined in my wcf service using jquery, then the wcf service and my application must be in the same solution. If I change the solutions for application and wcf service then I need to Enable cross domain ajax call in wcf service. For this I added Globl.asax file.

protected void Application_BeginRequest(object sender, EventArgs e)
{
HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
HttpContext.Current.Response.Cache.SetNoStore();

EnableCrossDmainAjaxCall();
}

private void EnableCrossDmainAjaxCall()
{
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Origin", "*");
if (HttpContext.Current.Request.HttpMethod == "OPTIONS")
{
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Methods", "GET, POST");
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Headers", "Content-Type, Accept");
HttpContext.Current.Response.AddHeader("Access-Control-Max-Age", "1728000");
HttpContext.Current.Response.End();
}
}
Then it works perfectly for ajax call through Jquery.

(2) After adding a Global.asax file in my wcf service, then I cant add an installer to my wcf service to host it as a windows service because of there OnStart and Application_BeginRequest
collisions.

Now these are my issues.
Hope you understand it.
   
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900