Use the nettcp-bound wcf host to iis7

Source: Internet
Author: User
Tags msmq connectionstrings

Maybe things are too complicated, and the memory is obviously reduced, and things you have done are easy to forget. The last successful deployment of the nettcp binding-based wcf to iis7 was forgotten.

Search for relevant information on the Internet and record the information for reuse.
1. Preparation: first, iis must be 7.0 or higher. At the same time, you must install Microsoft. NET Framework 3.5.1 In "enable or disable Windows ".Windows Communication Foundation HTTP Activation,Windows Communication Foundation Non-HTTP ActivationAnd Web management tools-IIS6 management compatibility-IIS metadatabase and IIS6 configuration compatibilityThese three functions (my system is the flagship version of win7)

In iis, I simply installed all the services.

2. Configure the website to support the nettcp Protocol
The firewall needs to open a hole in the nettcp service to allow ports: ipv2-4534

4502 :*
You can create a virtual directory for your website and confirm to enable the nettcp protocol.

(3) There is a cross-origin issue during access to wcf. In the wwwroot folder, the cross-origin access file and policy file clientaccesspolicy. xml and crossdomain. xml are placed under the website and directory. The file content is as follows:
Clientaccesspolicy. xml content:

<? Xml version = "1.0" encoding = "UTF-8"?>
<Access-policy>
<Cross-domain-access>
<Policy>
<Allow-from http-request-headers = "*">
<Domain uri = "*"/>
</Allow-from>
<Grant-to>
<Resource path = "/" include-subpaths = "true"/>
<Socket-resource port = "4502-4530" protocol = "tcp"/>
</Grant-to>
</Policy>
</Cross-domain-access>
</Access-policy>
Crossdomain. xml content:

<? Xml version = "1.0"?>
<Cross-domain-policy>
<Allow-access-from domain = "*"/>
</Cross-domain-policy>

Iii. Other considerations:

4. When adding a service reference to a Silverlight project, sometimes the cocouldNot loadFile or assembly 'System.ServiceModel. Activation. HttpModule'From assembly... In the command line, run C: \ Windows \ Microsoft. NET \ Framework \ v4.0.30319> aspnet_regiis.exe-iru to reinstall ASP. NET 4.0.

5. Pay attention to WAS startup

Windows (Process) Activation Service (WAS) is a new feature unique to IIS7.0. It is more powerful than the previous features of IIS 6.0, because it provides and supports more protocols except HTTP, for example, TCP and Pipe. Using WAS as the host of the Windows Communication Foundation, we can take full advantage of many advantages of WAS, because we no longer need to write a Host Program separately for a non-http wcf Service. The features of WAS allow our server programs to enjoy many features that only the traditional HTTP-based WCF Service can possess.
In Windows Vista/7/2008/R2, WAS is actually implemented by a separate Windows Service. In Windows Services, a Windows Service is called "Windows Process Activation Service ". From this point of view, WAS and IIS processes are physically isolated and can provide us with a flexible and stable WCF Service host environment. WAS's internal working mechanism is similar to ASMX WebService.
Three sets of network listeners (Listener) and listening Adapter are introduced on IIS 7 to implement network listening Based on TCP, Named Pipes and MSMQ. They are:
TCPListener | TCP Listener Adapter
NamedPipes Listener | Named Pipes Listener Adapter
MSMQ Listener | MSMQ Listener Adapter
The structure of IIS 7 is as follows:
 

Because IIS 7 supports non-HTTP network protocol-based listeners, this means that when we use IIS to host the WCF Service, you can use non-HTTP communication methods. TCPListener | the TCP Listener Adapter relies on the NetTcpPortSharing service to provide tcp port sharing for net. tcp binding. For details, refer to the sharing port that enables the WCF NetTcpBinding.

Article to learn it Network: http://www.xueit.com/html/2010-01-25/21-982353359406.html

Some references: http://archive.cnblogs.com/a/1883612/
Http://files.cnblogs.com/dhuxin/WCF.NetTCP%e7%bb%91%e5% AE %9a%e9%85%8d%e7%bd% AE %e8%af%b4%e6%98%8e.pdf
Http://www.cnblogs.com/chocstarfish/archive/2010/06/26/1765568.html
Http://www.singingeels.com/Articles/Duplex_WCF_Services_Hosted_in_IIS_Using_NetTcp.aspx
Http://www.cnblogs.com/cubean/archive/2009/08/28/1555223.html
Http://archive.cnblogs.com/a/1959748/
Iv. 1. My wcfweb configuration file

<? Xml version = "1.0"?>
<Configuration>

<System. web>
<Compilation debug = "true" targetFramework = "4.0">
<Assemblies>
<Add assembly = "System. Data. Entity, Version = 4.0.0.0, Culture = neutral, PublicKeyToken = b77a5c561934e089"/>
</Assemblies>
</Compilation>
</System. web>
<System. serviceModel>
<Bindings>
<NetTcpBinding>
<Binding name = "tcpBindingNoSecurity" receiveTimeout = "24.00: 00: 00">
<ReliableSession inactivityTimeout = "24.00: 00: 00"/>
<! -- Maximum size of data stream sent each time -->
<ReaderQuotas maxArrayLength = "2147483647" type = "regxph" text = "yourobjectname"/>
<Security mode = "None"/>
</Binding>
</NetTcpBinding>
</Bindings>
<Behaviors>
<ServiceBehaviors>
<Behavior>
<! -- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<ServiceMetadata httpGetEnabled = "true"/>
<! -- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<ServiceDebug includeExceptionDetailInFaults = "false"/>
<! -- Originally FALSE -->
<! -- Add a row here to start modifying the default serializable set length to 100 times the default value -->
<DataContractSerializer maxItemsInObjectGraph = "6553600"/>
<! -- Add the row here -->
</Behavior>
</ServiceBehaviors>
</Behaviors>
<! -- Add here -->
<Services>
<Service name = "ActService. Service">
<Endpoint address = "net. tcp: // 11.1.21.0: 4502/Service. svc"
Binding = "netTcpBinding" bindingConfiguration = "tcpBindingNoSecurity"
Contract = "ActService. IService"/>
<Endpoint address = "mex" binding = "mexHttpBinding" contract = "IMetadataExchange"/>
</Service>
</Services>

<! -- End adding here -->
<ServiceHostingEnvironment multipleSiteBindingsEnabled = "true"/>
</System. serviceModel>
<System. webServer>
<Modules runAllManagedModulesForAllRequests = "true"/>
</System. webServer>

<ConnectionStrings>
<Add name = "ActivitiesEntities" connectionString = "metadata = res: // */Activities. csdl | res: // */Activities. ssdl | res: // */Activities. msl; provider = System. data. sqlClient; provider connection string = & quot; Data Source = 4CB17D79510E48F; Initial Catalog = Activities; Integrated Security = True; MultipleActiveResultSets = True & quot; "providerName =" System. data. entityClient "/>

</ConnectionStrings>
<Deleetask>
<! --
==========================================
Custom database connection information
-->
<Add key = "ConnectionString" value = "Data Source = *. *; Initial Catalog = A; User ID = ad; Password = *"/>
</AppSettings>
</Configuration>
2. configuration file in silverlight:

<Configuration>
<System. serviceModel>
<Bindings>
<CustomBinding>
<Binding name = "NetTcpBinding_IService">
<BinaryMessageEncoding/>
<TcpTransport maxcompute edmessagesize = "2147483647" maxBufferSize = "2147483647"/>
</Binding>
</CustomBinding>
</Bindings>
<Client>
<Endpoint address = "net. tcp: // 10.2.21.13: 4502/ActService/Service. svc"
Binding = "customBinding" bindingConfiguration = "NetTcpBinding_IService"
Contract = "ActService. IService" name = "NetTcpBinding_IService"/>
</Client>
</System. serviceModel>
</Configuration>

3. configuration file of the web-based wcf Data Service

<? Xml version = "1.0" encoding = "UTF-8"?>
<! --
For more information on how to configure your ASP. NET application, please visit
Http://go.microsoft.com/fwlink? LinkId = 169433
-->
<Configuration>
<System. web>
<Compilation debug = "true" targetFramework = "4.0">
<Assemblies>
<Add assembly = "System. Data. Entity, Version = 4.0.0.0, Culture = neutral, PublicKeyToken = b77a5c561934e089"/>
</Assemblies>
</Compilation>
</System. web>
<ConnectionStrings>
<Add name = "ActivitiesEntities" connectionString = "metadata = res: // */Activities. csdl | res: // */Activities. ssdl | res: // */Activities. msl; provider = System. data. sqlClient; provider connection string = & quot; Data Source = 11.1.21.0; Initial Catalog = A; Persist Security Info = True; User ID = Ad; Password = 1; MultipleActiveResultSets = True & quot; "providerName =" System. data. entityClient "/>

</ConnectionStrings>
<System. serviceModel>
<ServiceHostingEnvironment aspNetCompatibilityEnabled = "true"/>
</System. serviceModel>

</Configuration>

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.