PDA

View Full Version : راه اندازی کامل WCF کمک کنید خیلی فوری



Boy_nn
شنبه 14 تیر 1393, 13:06 عصر
سلام دوستان
من الان یه پروژه با Wcf ساختم و به برنامه های تحت ویندوز و وب هم به صورت داخل یک کامپیوتر وصل کردم
الان می خوام فایل DLL wcf رو روی سرورم بزارم و برنامه هام از سایر کامپیوتر ها بتونن به سرویس دسترسی داشته باشند
هر چی گشتم نتونستم منبع معتبری پیدا کنم همه حداکثر در این حد رفتن که برنامه ها بتونن روی یک کامپیوتر اجرا بشن ممنون میشم کمک کنید

همه کاری کردم فقط نمی دونم چطوری باید publish کنم
همه منابعی که برای پابلیش هست برای Vs2010 هست که به خاطر تغییرات نمیشه مقایسه کرد ممنون میشم کسی از دوستان طریقه publish و نصب در iis ویندوز سرور رو توضیح بده

reza4zar
جمعه 03 مرداد 1393, 17:20 عصر
[*=left] Create WCF service
Create a new service using Create new WCF service library and test using WCFTestClient (http://dotnetmentors.com/how-to-start-with-creating-wcf-services-and-test-using-wcftestclient.aspx)
[*=left] Add Service Host Add service host for hosting Product Service by right clicking on Project from solution explorer. Name the service host as ProductServiceHost.svc
http://dotnetmentors.com/Images/ServiceHost.png
[*=left] ServiceHost tag Add below service host tag to ProductServiceHost.svc. Give fully qualified name of service to ServiceHost attribute. <%@ ServiceHost Service="NorthwindServices.ProductService" %>



[*=left] Create Web Site in IIS Open IIS manager by clicking Windows start -> Run -> enter inetmgr -> click ok If IIS is not installed on your machine click here (http://technet.microsoft.com/en-us/library/cc725762.aspx) to install.
Go to IIS manager and right click on sites and select Add Web site.
http://dotnetmentors.com/Images/IIS-AddWebSite.png

Enter details as shown in below picture


Enter site name as NorthwindServices
Change the application pool to ASP.net V4.0
Select the physical path of folder containing ProductServiceHost.svc
Enter port number on you wish to host service.

http://dotnetmentors.com/Images/IIS-Website.png

[*=left] Publish Services Go to your service application and right click on service project and select publish. http://dotnetmentors.com/Images/PublishWCFService.png
Enter target location as http://localhost:7741/
[*=left] Test the WSDL Open your browser and enter http://localhost:7741/ProductServiceHost.svc. You will see the link for WSDL. http://dotnetmentors.com/Images/ProductService.png

[*=left] Add Client Application Now add console application to solution. Name it as NorthwindApp. http://dotnetmentors.com/Images/ConsoleApp.png
[*=left] Add Service Reference Add service reference to NorthwindApp by right click on NorthwindApp project and click on Add Service Reference. Below window should appear. Enter the address of service endpoint which you have added in service app.config. http://dotnetmentors.com/Images/AddServiceRef.png

Enter ProductServiceRef for Namespace and click on OK. Service reference is added to your client application.

http://dotnetmentors.com/Images/ServiceRef.png

Check Client application's App.config, it should have service endpoint and client details.
[*=left] Client Implementation Service reference is now available for Northwind. We can call service operations. Add the below code to NorthwindApp -> Program.cs file. class Program
{
static void Main(string[] args)
{
ShowOperations();
}

private static void ShowOperations()
{
ConsoleKeyInfo cki;

do
{
Console.WriteLine();
Console.WriteLine("Enter Product ID or press Esc to quit : ");
cki = Console.ReadKey();
if (!char.IsNumber(cki.KeyChar))
{
Console.WriteLine(" Invalid number");
}
else
{
Int32 number;
if (Int32.TryParse(cki.KeyChar.ToString(), out number))
{
Console.WriteLine();
GetProductName(number);
GetProductQty(number);
GetCategoryName(number);
}
else
{
Console.WriteLine("Unable to parse input");
}
}
} while (cki.Key != ConsoleKey.Escape);

Console.Read();
}

private static void GetProductName(int ProductID)
{
ProductsClient client = new ProductsClient();
string ProductName = client.GetProductName(ProductID);
Console.WriteLine(string.Format("Product name {0} for Product ID {1}",
ProductName, ProductID));
}

private static void GetProductQty(int ProductID)
{
ProductsClient client = new ProductsClient();
int ProductQty = client.GetProductQty(ProductID);
Console.WriteLine(string.Format("Product qty {0} for Product ID {1}",
ProductQty, ProductID));
}

private static void GetCategoryName(int ProductID)
{
ProductsClient client = new ProductsClient();
string CategoryName = client.GetCategoryName(ProductID);
Console.WriteLine(string.Format("Category name {0} for Product ID {1}",
CategoryName, ProductID));
}
}

reza4zar
جمعه 03 مرداد 1393, 17:21 عصر
سلام دوست عزیز حوصله نداشتم خودم مراحل انجام بدم ار اینترنت مطلب بالا را قرار دادم اما اگه مشکلت حل نشد بگو خودم برات مراحل جزئی تر انجام بدم