Get the App
SLTechnology News&Howtos  ›  Development  › 

How to configure the section for WCF services

Shulou Source: shulou.com Published: 2022-06-02 07:41:36 10月05日 Update

This article will explain in detail how to configure WCF services for you. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

With the rapid development of WCF, its performance has also increased, but there are a lot of people have a headache about configuration files, so let's teach you now. Multiple services can be defined in the WCF services configuration section, and each service is placed in the service configuration section, and the WCF host program can find these defined services and publish them through the configuration file. The WCF services configuration section contains name and behaviorConfiguration attributes. Where name is configured with a type name that implements ServiceContract. The type name must fully contain the namespace and type name.

The configuration value of behaviorConfiguration is related to the contents of the subsequent behaviors configuration section. Endpoint is the body of the service configuration section, where the endpoint configuration section contains three components of endpoint: Address, Binding, and Contract. Because the specific binding configuration is done in the bindings configuration section, the bindingConfiguration property is configured in endpoint to point to the specific binding configuration. As follows:

Services servicename= "BruceZhang.MyService" behaviorConfiguration= "MyBehavior" endpointaddress= "binding=" netTcpBinding "bindingConfiguration=" DuplexBinding "contract=" BruceZhang.IHello "/ / service / services

We can also define multiple endpoint, for example:

Services service name= "Microsoft.ServiceModel.Samples.CalculatorService" behaviorConfiguration= "CalculatorServiceBehavior" endpointaddress= "binding=" wsHttpBinding "contract=" Microsoft.ServiceModel.Samples.ICalculator "/ endpointaddress=" mex "binding=" mexHttpBinding "contract=" Microsoft.ServiceModel.Samples.IMetadataExchange "/ / service / services

If the address value is empty, then the address of endpoint is the default base address (BaseAddress). For example, the address of the ICalculator service is http://localhost/servicemodelsamples/service.svc, while the address of the IMetadataExchange service is http://localhost/servicemodelsamples/service.svc/mex. The so-called base address can be defined by configuring host in the WCF services configuration section:

Service name= "Microsoft.ServiceModel.Samples.CalculatorService" behaviorConfiguration= "CalculatorServiceBehavior" host baseAddresses addbaseAddress= "http://localhost/ServiceModelSamples/service.svc"/ / baseAddresses / host endpoint... / / this is the end of the service article on "how to configure WCF services". I hope the above content can be helpful to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Tags: Configuration service address article type content base base address multiple that is attributes files more related good headache practical three subject can be passed through Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Shulou Technology Docker macOS MySQL