WCF-Step-by-step publishing of WCF services to IIS

Source: Internet
Author: User

WCF-Step-by-step publishing of WCF services to IIS (figure)

Use the VS-Bring-wcfsvchost (WCF Service Host) to publish WCF services, which are always used by developers for testing.

Let's look at how to publish a WCF service in central IIS.

The environment is VS 2008 (the company computer does not have VS2010 installed) ^_^

We start from the beginning, do not write code, full configuration, will reap no small.

Create a new WCF service library

Building a WCF Service application

The results are as follows

Remove the default files that are not needed in the WCF program, such as

Add a WcfServiceLibrary1 reference to the WcfService1 project, such as.

Modify the declaration instructions so that the backend code for this service.svc file points to the service class in the WCF Service Library project--wcfservicelibrary1 project that we created, and the following code is changed:

<%@ ServiceHost language= "C #" debug= "true" service= "Wcfservicelibrary1.service1"%>

Ctrl+shift+b Compile the solution, configure the tool with the reflection, first compile before the line

At this point, our WCF Service site does not publish the services and endpoints in the WCF service library, and we need to do a series of configuration work on Web. config.

Right-click the Web. config file that we want to configure, edit the WCF configuration

In the Service Configuration window that pops up, assign the Service1 service to the Wcfservicelibrary1.service1 service class in WcfServiceLibrary1.dll of the WCF Service library.

The contract of one of the external endpoints is then set to the Wcfservicelibrary1.iservice1 service contract in the WCF Service Library's WcfServiceLibrary1.dll.

This step is optional, and we will add an endpoint for this WCF Service site, configured as

Below we will try to use different endpoints to interact with the WCF service to see how it works.

When we use IIS5 or IIS6 to publish WCF services, we typically create only HTTP bound endpoints, not endpoints that use TCP bindings, pipe bindings.

Testing Services

Right-click on the Service1.svc and select "View in Browser" to run the service in IE.

As a result we see that we can publish our WCF services in ASP. NET Development Server.

Right-WcfService1 The project, locate the Web tab, use IIS debugging, and deploy it on the IIS virtual directory.

Set the default startup page to Service1.svc Press F5

In the WCF test client calls the WCF service we just published in IIS, about more WCF Test clients (WcfTestClient.exe)

Note that using the Command Prompt window, run wcftestclient

Add the service and enter the address of the service, which is required

Have to sigh, Microsoft's things are easy to use AH.

We can see that there are two endpoints in the published service: The two endpoints are transmitted in different ways, but the methods provided are the same.

Additional content

You can integrate multiple WCF service libraries into WcfService1 by using the above method, try it.

Source code: Wcfiis.rar

WCF-Step-by-step publishing of WCF services to IIS (figure)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.