WCF 通信
来源:互联网 发布:java 字符串搜索 编辑:程序博客网 时间:2024/05/16 05:08
定义一个WCF service类
[ServiceContract] public interface ISimpleService { [OperationContract] string SimpleMethod(string msg); } class SimpleService : ISimpleService { public string SimpleMethod(string msg) { Console.WriteLine("The caller passed in " + msg); return "Hello " + msg; } }
WCF 服务发布有两种方式1:config文件,2:代码发布
- 使用config来发布WCF,
- service结点 ? 各自的作用
- behavior结点
- endpoint结点 定义发布协议?
一个定义好的config文件:
<system.serviceModel>
<services>
<service
name="Microsoft.ServiceModel.Samples.CalculatorService"
behaviorConfiguration="CalculatorServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8000/ServiceModelSamples/service"/>
</baseAddresses>
</host>
<!-- this endpoint is exposed at the base address provided by host: http://localhost:8000/ServiceModelSamples/service -->
<endpoint address=""
binding="wsHttpBinding"
contract="Microsoft.ServiceModel.Samples.ICalculator" />
<!-- the mex endpoint is exposed at http://localhost:8000/ServiceModelSamples/service/mex -->
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
<!--For debugging purposes set the includeExceptionDetailInFaults attribute to true-->
<behaviors>
<serviceBehaviors>
<behavior name="CalculatorServiceBehavior">
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
- 客户端接收的过程:
1:在config文件中指定server端url,
如<client>
<endpoint name=""
address="http://localhost:8000/servicemodelsamples/service"
binding="wsHttpBinding"
contract="Microsoft.ServiceModel.Samples.ICalculator">
</endpoint>
</client>
2:定义相对于服务器段的接口 然后实现这个接口,这个接口其实就是server类在客户端的代理,然后就可以在客户段使用代理类了
疑点:1: 服务--客户之间协议的选择
- WCF 通信
- 说说WCF通信安全
- 说说WCF通信安全
- wcf客户间通信
- WCF通信简单示例
- WCF双工通信
- Silverlight WCF通信
- WCF的通信模式
- WCF实现双工通信
- WCF通信模式
- WCF 入门 通信
- WCF通信模式
- WCF入门教程五[WCF的通信模式]
- WCF入门教程五[WCF的通信模式]
- WCF与Flex的通信
- java与wcf通信例子
- silverlight中Wcf双工通信
- WCF中实现双工通信
- PCSC那事儿(十六--SCardListReaders)
- 100Base-T,100Base-TX等的含义与区别
- 主从表设计和编程的几种实现办法
- PCSC那事儿(十七--SCardGetStatusChange)
- 人生感悟
- WCF 通信
- 移植 u-boot 1.1.6 到 S3C2440 (nand 启动)
- XML 解析c++源码(头文件)
- 职场
- Visual C++ 使用的文件(转)
- VSS 错误:File names.dat may be corrupt 修复
- VC-Project/Settings说明
- 人生哲理寓言
- XML 解析c++源码(源文件)