WCF-based configuration services

Source: Internet
Author: User

Configuring the service in WCF application programming is a major part of it.

Configurations can define and customize how services are exposed to clients, including service addresses, the transmission and encoding of messages sent and received, and the security type of the service.

There are two configurations of services: encoding and using config files, most of which are configured with configuration files.

<system.serviceModel>  <!--services--  <services>    <service>      

Structure as above.
Service: There are two properties for name and behaviorconfiguration, name is qualified, consists of namespace and class name, such as Name= "namespace. Implementation Class".

Endpoint:address a unified resource identifier, either an absolute address or a relative service address, if empty, the same as the base site; Bing determines the type of transport protocol, security and usage encoding, and whether reliable sessions, things, or streams are supported or enabled ; Bingdingconfiguration: This can refer to this http://www.cnblogs.com/artech/archive/2011/09/19/defaultbinding.html;

Contract: Is the interface of the service

<endpoint address="" binding="basichttpbinding" contract= " Wcfservicecontract.iservice1">

Binding: Each endpoint requires the correct binding, and the information it binds may be very basic or complex. WCF has many bindings, such as BasicHttpBinding, Wshttpbinding, NetNamedPipeBinding, and netmsmqbinding, which are commonly used, including protocols, encodings, and transports. There is also the use of custombinding according to the actual situation.

These are not said, this book can be divided into a few chapters to write, the introduction of the words as long as you know what is necessary, what is good, can be used in code and configuration files to configure the service, this I have written to vomit, I paste the copy directly. If you do not, please write more!

Uri baseaddress =NewUri ("Http://localhost:8000/MyService"); ServiceHost Host=NewServiceHost (typeof(Xiyiji), baseaddress); Host. AddServiceEndpoint (typeof(Ihellowcfservice),NewWshttpbinding (),"XiyijiWcfservice"); ServiceMetadataBehavior SMB=NewServiceMetadataBehavior (); Smb. Httpgetenabled=true; Host.            DESCRIPTION.BEHAVIORS.ADD (SMB); Host.            Open (); Console.WriteLine ("Service to open"); Console.readkey ();

The above is the code to configure, the following is the configuration file configuration

<system.serviceModel> <services> <service name="Wcfapplication1.xiyiji" behaviorconfiguration=" metechanged  "> "Http://localhost:8000/MyService"/> </baseAddresses> "Xiyijiwcfservice"binding="Wshttpbinding"contract="Wcfapplication1.ixiyijiservice"/> </service> </services> <behaviors> <serviceBehaviors> <behavior na Me="metechanged"> <servicemetadata httpsgetenabled="true"/> </behavior> </serviceBehaviors> </behaviors> </system.serviceModel>

I don't know if anyone is like me, just leave a link. http://q.cnblogs.com/q/74606/

WCF-based configuration services

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.