Services, Behaviors, and Bindings
When using WCF, there are three things that you need to configure in web.config
: Services, Behaviors, and Bindings.
The Service setting is important for two things: First, the location of the behavior (explained more in the next bullet), and second, the type of service, defined using its namespace, in this case Devx.Indigo.Samples.TemperatureService
element has a child <endpoint>
element where you specify the binding (more on this later) and the contract. The contract is defined by the interface (from Listing 1
) using its fully qualified name.
|Figure 1. Running the WCF Service: After creating the service, when you access it from a browser, you will see a screen similar to this that shows how to use the service.|
element lets you configure how the service should react under particular circumstances. It needs a configurationName
attribute so that the service can map to it. In Listing 2
, the service has been configured to return any unknown exceptions as faults.
You define the bindings and the binding types within the bindings
element. In this case, the element is simple, specified as an HTTP type binding, identified as Binding1
. Check the MSDN documentation and the schema (defined at the top of this config file) for more options.
Save the web.config
file in the same directory as your application, and you're almost ready to go.
The final thing you need is the service mapper
. Create a text file in the tconvert
directory and call it "service.svc
." It should contain the following single line of code:
<@Service language=c# Debug="true"
Your Indigo service is now ready to go. You access it via the URL: http:///TemperatureService/service.svc
. You can see the results of this in Figure 1