`

WCF(1)

    博客分类:
  • WCF
 
阅读更多

 

  1. WCF:Windows Communication Fundation (windows 通讯接口).
  2. WCF本质上提供一个跨进程、跨机器以致跨网络的服务调用.
  3. WCF的服务不能孤立地存在,需要寄宿于一个运行着的进程中,我们把承载WCF服务的进程称为宿主,为服务指定宿主的过程称为服务寄宿(Service Hosting)。在我们的计算服务应用中,采用了两种服务寄宿方式:通过自我寄宿(Self-Hosting)的方式创建一个控制台应用作为服务的宿主(寄宿进程为Hosting.exe);通过IIS寄宿方式将服务寄宿于IIS中.
  4. WCF广泛采用基于自定义特性(Custom Attribtue)的声明式编程模式,我们通过在接口上应用System.ServiceModel.ServiceContractAttribute特性将一个接口定义成服务契约。
  5. WCF是一个基于消息的通信框架,采用基于终结点(Endpoint)的通信手段。终结点由地址(Address)、绑定(Binding)和契约(Contract)三要素组成,由于三要素应为首字母分别为ABC,所以就有了易于记忆的公式:Endpoint = ABC。
  6. 每一个ASP.NET Web服务都具有一个.asmx文本文件,客户端通过访问.asmx文件实现对相应Web服务的调用。与之类似,每个WCF服务也具有一个对应的文本文件,其文件扩展名为.svc。
  7. 如果要把服务挂载在iis上记得把Service 的属性的输出路径设置为bin,还有web.config文件的属性设置为copy always。
  8. "The page you are requesting cannot be served because of the extension configuration...." 解决方法:

    i)Run Visual Studio 2008 Command Prompt as “Administrator”.Navigate to ii)C:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication Foundation.
    iii)Run this command servicemodelreg –i.

  9. HTTP Error 403.14 - Forbidden

    The Web server is configured to not list the contents of this directory.

    Solution - 

    To resolve this problem, follow these steps:

    i) Start IIS Manager. To do this, click Start, click Run, type inetmgr.exe, and then click OK.

    ii) In IIS Manager, expand server name, expand Web sites, and then click the Web site that you want to modify.

    In Features view, double-click Directory Browsing.

    iii) In the Actions pane, click Enable.


  10. the solution of "Unable to automatically debug "***". the remote.........." is that: set the property"debug" of node "compilation" to "true" of web.config file of service. if can't slove the porblem, try to restart the vs.
  11. Message:  Attaching to this process can potentially harm your computer.  If the information below looks suspicious or you are unsure, do not attach to this process.

    The solution for me was just a few steps...

    1. Close all Visual Studio instances.
    2. Ensure that you are a member of the local debuggers group (Control Panel, Administrative Tools, Local Security Policy, Security Settings, Local Poliies, User Rights Assignment, Debug Programs). 
    3. Change the following registry key  HKCU\Software\Microsoft\VisualStudio\10.0\Debugger\DisableAttachSecurityWarning from 0 to 1.
    4. Restart Visual Studio. 
  12. 在WCF预定义绑定类型中,WSDualHttpBindingNetTcpBinding均提供了对双工通信的支持,但是两者在对双工通信的实现机制上却有本质的区别。WSDualHttpBinding是基于HTTP传输协议的;而HTTP协议本身是基于请求-回复的传输协议,基于HTTP的通道本质上都是单向的。WSDualHttpBinding实际上创建了两个通道,一个用于客户端向服务端的通信,而另一个则用于服务端到客户端的通信,从而间接地提供了双工通信的实现。而NetTcpBinding完全基于支持双工通信的TCP协议。HTTP是应用层协议,TCP是传输层协议!数据包在网络传输过程中,HTTP被封装在TCP包内!是TCP协议族中的一种。使用TCP80端口
  13. Socket,Remoting(TCP,HTTP),WebService(HTTP),WCF(HTTP,TCP,PIPE)
  14. wcf 服务可以挂载在console application, windows application, windows service, IIS.
  15. wcf的优势:统一性(是对webservice,remoting,socket等技术的整合),安全性,互操作性(wcf最基本的通信机制是soap的,可以跨平台,跨机器,跨进程),兼容性(兼容旧的webservice和remoting等技术的应用程序)
  16. 我们可以把WCF看成是一个完全处理XML Message的构架,通常我们使用.NET对象来封装我们的数据。如何使我们创造的对象能够有效地转化成结构化的XML,就是通过序列化—Serialization。Serialization可以看成是把包含相同内容的数据从一种结构 (.NET Object) 转换成另一种结构(xml),在WCF中的Serialization可以看成是Serializer(序列化器)通过反射的机制分析对象所对应的Type的原数据,从而提供一种算法实现Managed Type的XSD的转化。
  17. 很多刚刚接触WCF的人往往不能很好地区分Serialization和Encoding。我们的.NET Object通过Serialization转化成XML Infoset。但是要使我们的数据能够通过网络协议在网络上传递,必须把生成的XML Infoset转化成字节流(Byte Stream)。所以Encoding关注的是XML Infoset到字节流(Byte Stream)这一段转化的过程。在WCF中,有3中不同的方式可供选择:Binary;Text和MTOM(Message Transmit Optimized Mechanism)消息传输优化机制。Binary具有最好的Performance,Text具有最好的互操作性,MTOM则有利于大量数据的传送。

    我们可以这样来理解Serialization和Encoding,Sterilization是基于Service Contract的——而实际上它也是定义在Service Contract中,是放在我们的Code中;而Encoding一般由Binding提供,它是和Service无关的,我们一般在Configuration中根据实际的需要选择我们合适的Encoding。WCF把Serialization和Encoding相互分离是有好处的,Serialization手部署环境的影响相对不大,具有相对的通用性,而Encoding则关系到访问Service的性能以及互操作性等方面,和部署环境紧密相关。比如对于一个在一个Intranet内部使用的系统,往往处于提高Performance考虑,我们一般是使用TCP Transport结合Binary 的Encoding,可能在某一天出现的来自于Internet的潜在的调用,我们不得不改用Http作为Transport,并使用Text Encoding。由于Encoding是可配置的,所以在这种情况下,我们只需要改变Configuration文件就可以了。

  18. Wcf 中用到wshttpbinding和basichttpbinding的区别是:basichttpbinding发送的数据是不加密的,明文的;而wshttpbinding发送的时加密的数据;
  19. 1
  20. 1
  21. 1
  22. 1
  23. 1
  24. 1
  25. 1
  26. 1
  27. 1
  28. 1
  29. 1
  30. 1
  31. 1
  32. 1
  33. 11
  34. 1
  35. 1
  36. 1
  37. 1
  38. 1
  39. 1
  40. 1
  41. 1
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics