How to host the WCF NetTcpBinding Service in IIS

Source: Internet
Author: User

This blog will show you how to host NetTcpBinding services in IIS.

1. Prepare the service code first.

Contract

namespacecontract{[ServiceContract] Public Interfaceicalculate {[OperationContract]DoubleADD (DoubleXDoubley); [OperationContract]DoubleSubtract (DoubleXDoubley); [OperationContract]DoubleMultiply (DoubleXDoubley); [OperationContract]DoubleDivide (DoubleXDoubley); }}

Service

namespaceservice{ Public classCalculate:icalculate { Public DoubleADD (DoubleXDoubley) {returnX +y; }         Public DoubleDivide (DoubleXDoubley) {returnX-y; }         Public DoubleMultiply (DoubleXDoubley) {returnX *y; }         Public DoubleSubtract (DoubleXDoubley) {returnX/y; }    }}

Web. config

<?XML version= "1.0" encoding= "Utf-8"?><Configuration>    <Startup>         <supportedruntimeversion= "v4.0"SKU=". netframework,version=v4.5.2 " />    </Startup>  <System.ServiceModel>    <Behaviors>      <servicebehaviors>        <Behaviorname= "Messagebehavior">          <Servicemetadata/>          <ServicedebugIncludeexceptiondetailinfaults= "true"/>          <DataContractSerializerMaxitemsinobjectgraph= "65535" />        </Behavior>      </servicebehaviors>    </Behaviors>    <Services>      <Servicename= "Service.calculate"behaviorconfiguration= "Messagebehavior">        <EndpointAddress= "Net.tcp://172.18.20.67:9998/calculateservice.svc"binding= "NetTcpBinding"Contract= "Contract.icalculate" />        <EndpointAddress= "Mex"binding= "Mextcpbinding"Contract= "IMetadataExchange"/>      </Service>    </Services>  </System.ServiceModel></Configuration>

Svc

<Service= "service.calculate"%>

To configure the IIS environment, you need to turn non-http activation on,

Next, create a website to host the WCF service.

1). Add the NET.TCP protocol to the Advanced settings

2). Add port numbers that need to be open in the bindings of website, for example, to open 9998,


Finally, you need to enable access to ports in Windows Firewall.

So the entire configuration is complete.

How to host the WCF NetTcpBinding Service in IIS

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.