i have created a wcf ret service using VS 2013/ using ,net 4.5 fw. which connects to a sql db and fetch records.
now i need to deploy this wcf service onto a different server with a different port number [other than 80 ] and consume it from ajax jquery html controls.
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
namespace NPDWCFService
{
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "NPDRESTService" in code, svc and config file together.
// NOTE: In order to launch WCF Test Client for testing this service, please select NPDRESTService.svc or NPDRESTService.svc.cs at the Solution Explorer and start debugging.
public class NPDRESTService : INPDRESTService
{
private static string strConn;
public void DoWork()
{
}
//public string GetProducts(string ProductId)
//{
// return "get all products with product id " + ProductId + " was successful";
//}
static string strConn1 = @"Data Source=srv1;Initial Catalog=Products;Integrated Security=True";
public List<Product> GetAllProducts()
{
var productList = new List<Product>();
SqlDataReader reader = null;
SqlConnection myConnection = new SqlConnection();
Product objallproducts = new Product();
//Server = myServerAddress; Database = myDataBase; User Id = myUsername; Password = myPassword;
myConnection.ConnectionString = strConn1;
SqlCommand sqlCmd = new SqlCommand();
sqlCmd.CommandType = CommandType.Text;
sqlCmd.CommandText = "Select * from tblProducts"; // where ProductId=" + id + "";
sqlCmd.Connection = myConnection;
myConnection.Open();
reader = sqlCmd.ExecuteReader();
Product prodd = null;
while (reader.Read())
{
prodd = new Product();
prodd.ProductID = Convert.ToInt32(reader.GetValue(0));
prodd.ProductName = reader.GetValue(1).ToString();
prodd.ProductCategory = reader.GetValue(2).ToString();
prodd.Price = Convert.ToInt32(reader.GetValue(3));
productList.Add(prodd);
}
// return prodd;
myConnection.Close();
return productList;
//Code logic to get all students.
}
i have created a website from iis and given this url in the publish --> web deploy --> destination url as : http://localhost:8089/
so, I need to select asp.net 4.0 as the appln pool , which I have not done previously.
so I am trying to configure asp.net 4.0 appln pool :
I have win server 2012 r2 STD as the windows os . I have configured iis long back including the asp.net 3.5 and 4.5 extensibility etc.
but when I tried to add a website for this wcf service in IIS, and when I tried to select application pool, am not able to see , asp.net 4.0 / 4.5 in the list.
went to net framework 4.0.030319 directory and tried to run the aspnet_regiis -ir command . but it gave me a message . but the appln pool is not created.
Microsoft (R) ASP.NET RegIIS version 4.0.30319.33440 Administration utility to install and uninstall ASP.NET on the local machine. Copyright (C) Microsoft Corporation. All rights reserved. Start installing ASP.NET (4.0.30319.33440). This option is not supported
on this version of the operating system. Administr ators should instead install/uninstall ASP.NET 4.5 with IIS8 using the "Turn Win dows Features On/Off" dialog, the Server Manager management tool, or the dism.e xe command line tool. For more details please
see http://go.microsoft.com/fwlin k/?LinkID=216771. Finished installing ASP.NET (4.0.30319.33440).
>> Administr ators should instead install/uninstall ASP.NET 4.5 with IIS8 using the "Turn Win dows Features On/Off" dialog, the Server Manager management tool, or the dism.e xe command line tool
Per this error message, it seems you did not install Asp.net 4.5 under IIS 8. I suggest you follow the link from kaushalparik... to configure your IIS before publishing service to IIS.
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Member
13 Points
78 Posts
deploy wcf service on a different server and consume it from ajax, jquery controls
Mar 02, 2017 06:36 AM|SaMolPP|LINK
i have created a wcf ret service using VS 2013/ using ,net 4.5 fw. which connects to a sql db and fetch records.
now i need to deploy this wcf service onto a different server with a different port number [other than 80 ] and consume it from ajax jquery html controls.
i have created a website from iis and given this url in the publish --> web deploy --> destination url as : http://localhost:8089/
All-Star
31342 Points
7050 Posts
Re: deploy wcf service on a different server and consume it from ajax, jquery controls
Mar 02, 2017 08:53 AM|kaushalparik27|LINK
What is the issue that you are facing?
[KaushaL] Blog Twitter [MS MVP 2008 & 2009] [MCC 2011] [MVP Reconnect 2017]
Don't forget to click "Mark as Answer" on the post that helped you
Member
13 Points
78 Posts
Re: deploy wcf service on a different server and consume it from ajax, jquery controls
Mar 02, 2017 11:06 AM|SaMolPP|LINK
How to publish this web service onto a different server, and consume it from jQuery ajax, html controls and bind those values.
All-Star
31342 Points
7050 Posts
Re: deploy wcf service on a different server and consume it from ajax, jquery controls
Mar 02, 2017 11:38 AM|kaushalparik27|LINK
There is no difference in publishing WCF to publishing a website. You can create a website/virtual directory and point to WCF application folder.
Here is a step by step guide: IIS 8.0 Using ASP.NET 3.5 and ASP.NET 4.5 : The Official Microsoft IIS Site
[KaushaL] Blog Twitter [MS MVP 2008 & 2009] [MCC 2011] [MVP Reconnect 2017]
Don't forget to click "Mark as Answer" on the post that helped you
Member
13 Points
78 Posts
Re: deploy wcf service on a different server and consume it from ajax, jquery controls
Mar 02, 2017 12:40 PM|SaMolPP|LINK
Am getting the error :
Request Error
The server encountered an error processing the request. See server logs for more details.
when i tried to publish this service.
All-Star
31342 Points
7050 Posts
Re: deploy wcf service on a different server and consume it from ajax, jquery controls
Mar 02, 2017 12:55 PM|kaushalparik27|LINK
can you provide detail on when exactly this happens? Is the error occurring when you try to browse? You may look below links on similar topic:
[KaushaL] Blog Twitter [MS MVP 2008 & 2009] [MCC 2011] [MVP Reconnect 2017]
Don't forget to click "Mark as Answer" on the post that helped you
Member
13 Points
78 Posts
Re: deploy wcf service on a different server and consume it from ajax, jquery controls
Mar 02, 2017 01:04 PM|SaMolPP|LINK
am sorry, I am unable to see asp.net 4 / asp.net 4.5 application pool in y IIS 8.0
I checked this video : https://www.youtube.com/watch?v=g-w1GvkwErk
https://www.youtube.com/watch?v=PBAs3zw6rq0
so, I need to select asp.net 4.0 as the appln pool , which I have not done previously.
so I am trying to configure asp.net 4.0 appln pool :
I have win server 2012 r2 STD as the windows os . I have configured iis long back including the asp.net 3.5 and 4.5 extensibility etc.
but when I tried to add a website for this wcf service in IIS, and when I tried to select application pool, am not able to see , asp.net 4.0 / 4.5 in the list.
went to net framework 4.0.030319 directory and tried to run the aspnet_regiis -ir command . but it gave me a message . but the appln pool is not created.
C:\Windows\Microsoft.NET\Framework\v4.0.30319>iisreset
Attempting stop... Internet services successfully stopped Attempting start... Internet services successfully restarted
C:\Windows\Microsoft.NET\Framework\v4.0.30319>ASPNET_regiis.exe -i
Microsoft (R) ASP.NET RegIIS version 4.0.30319.33440 Administration utility to install and uninstall ASP.NET on the local machine. Copyright (C) Microsoft Corporation. All rights reserved. Start installing ASP.NET (4.0.30319.33440). This option is not supported on this version of the operating system. Administr ators should instead install/uninstall ASP.NET 4.5 with IIS8 using the "Turn Win dows Features On/Off" dialog, the Server Manager management tool, or the dism.e xe command line tool. For more details please see http://go.microsoft.com/fwlin k/?LinkID=216771. Finished installing ASP.NET (4.0.30319.33440).
C:\Windows\Microsoft.NET\Framework\v4.0.30319>
All-Star
31342 Points
7050 Posts
Re: deploy wcf service on a different server and consume it from ajax, jquery controls
Mar 02, 2017 01:12 PM|kaushalparik27|LINK
There are only two base CLR version that you should be able to see:
Since you are working with framework 4.5, you should select CLR Version v4.0.30319.
[KaushaL] Blog Twitter [MS MVP 2008 & 2009] [MCC 2011] [MVP Reconnect 2017]
Don't forget to click "Mark as Answer" on the post that helped you
Contributor
3290 Points
1595 Posts
Re: deploy wcf service on a different server and consume it from ajax, jquery controls
Mar 31, 2017 07:00 AM|Edward Z|LINK
>> Administr ators should instead install/uninstall ASP.NET 4.5 with IIS8 using the "Turn Win dows Features On/Off" dialog, the Server Manager management tool, or the dism.e xe command line tool
Per this error message, it seems you did not install Asp.net 4.5 under IIS 8. I suggest you follow the link from kaushalparik... to configure your IIS before publishing service to IIS.
# IIS 8.0 Using ASP.NET 3.5 and ASP.NET 4.5
https://www.iis.net/learn/get-started/whats-new-in-iis-8/iis-80-using-aspnet-35-and-aspnet-45
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.