Service Configuration
Retired Content |
---|
The Web Service Software Factory is now maintained by the community and can be found on the Service Factory site. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. Retired: November 2011 |
The server that hosts a WCF service must be configured to define the address, binding type, and service contract that are used by that service. The following code is an example of a configuration used to host a WCF service in IIS.
<configuration>
<system.serviceModel>
<services>
<service name="Service ">
<endpoint
address="EmployeeService"
binding="basicHttpBinding"
contract="IEmployeeService "/>
</service>
</services>
</system.serviceModel>
</configuration>
The binding information is used to identify the transport protocol supported by a specific service. The table below describes all the bindings currently provided by WCF. It is also possible to create your own bindings, which means that you can use any protocol you want for communication.
Name |
Description |
---|---|
BasicHttpBinding |
Interoperability with Web services and client applications supporting the WS-BasicProfile 1.1 and Basic Security Profile 1.0. |
WSHttpBinding |
Interoperability with Web services and client applications supporting the WS-* protocols over HTTP. |
WSDualHttpBinding |
Duplex HTTP communication, by which the receiver of an initial message will not reply directly to the initial sender but may transmit any number of responses over a period of time. |
WSFederationBinding |
HTTP communication, in which access to the resources of a service can be controlled based on credentials issued by an explicitly-identified credential provider. |
NetTcpBinding |
Secure, reliable, high-performance communication between Windows Communication Foundation software entities across a network. |
NetNamedPipeBinding |
Secure, reliable, high-performance communication between Windows Communication Foundation software entities on the same computer. |
NetMsmqBinding |
Communication between Windows Communication Foundation software entities through Message Queuing. |
MsmqIntegrationBinding |
Communication between a Windows Communication Foundation software entity and another software entity through Message Queuing. |
NetPeerTcpBinding |
Communication between Windows Communication Foundation software entities through Windows Peer-to-Peer Networking. |
WebHttpBinding |
Used to configure endpoints for Windows Communication Foundation Web services that are exposed through HTTP requests instead of SOAP messages. |
The previous service configuration example only briefly describes the minimum information that is needed to host a WCF service. As you can imagine, many other configuration elements can be used to control behaviors, security, tracing, and many other features provided by WCF. The Windows SDK for .NET Framework 3.x provides a tool named the Service Configuration Editor that can be used to configure all these different features without having to manually modify the configuration file.
Using .asmx for WCF Services
If required, WCF applications can also be configured to use .asmx as the file name extension for their service files instead of the .svc file name extension used by WCF. The following example demonstrates how to configure a service to use the .asmx file extension.
<system.web>
<compilation>
<compilation debug="true">
<buildProviders>
<remove extension=".asmx"/>
<add extension=".asmx"
type="System.ServiceModel.ServiceBuildProvider,
Systemm.ServiceModel,
Version=3.0.0.0,
Culture=neutral,
PublicKeyToken=b77a5c561934e089" />
</buildProviders>
</compilation>
</compilation>
</system.web>