案例下載
http://download.csdn.net/detail/woxpp/4113172
服務端配置代碼
<system.serviceModel><services><service name="WcfServiceLibrary.ServiceTcp"><endpoint address="net.tcp://localhost:8731/WcfServiceLibrary"binding="netTcpBinding" bindingConfiguration="testnetTcpBinding"contract="WcfServiceLibrary.IServiceTcp"><identity><dns value="localhost" /></identity></endpoint><endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /><host><baseAddresses><add baseAddress="http://localhost:8732/WcfServiceLibrary" /></baseAddresses></host></service></services><behaviors><serviceBehaviors><behavior><!-- 為避免泄漏元數據信息,請在部署前將以下值設置為 false 并刪除上面的元數據終結點 --><serviceMetadata httpGetEnabled="True"/><!-- 要接收故障異常詳細信息以進行調試,請將以下值設置為 true。在部署前設置為 false 以避免泄漏異常信息--><serviceDebug includeExceptionDetailInFaults="False" /></behavior></serviceBehaviors></behaviors><bindings><netTcpBinding><binding name="testnetTcpBinding"><security mode="None"></security></binding></netTcpBinding></bindings></system.serviceModel>
wcf服務是什么。客戶端調用代碼? 通過代理 代理生成 參見
http://www.cnblogs.com/woxpp/p/6232298.html
客戶端調用代碼?
private void btnTest_Click(object sender, EventArgs e){NetTcpBinding netTcp = new NetTcpBinding();ChannelFactory<IServiceTcp> ftc = new ChannelFactory<IServiceTcp>();netTcp.Security.Mode = SecurityMode.None;IServiceTcp proxy = ChannelFactory<IServiceTcp>.CreateChannel(netTcp, new EndpointAddress("net.tcp://127.0.0.1:8731/WcfServiceLibrary"));txtMessage.Text = proxy.GetDataUsingDataContract(new WcfServiceLibrary.CompositeType() { StringValue = "sssss" }).StringValue;}
?