惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Y
Y Combinator Blog
博客园 - 司徒正美
TaoSecurity Blog
TaoSecurity Blog
Martin Fowler
Martin Fowler
T
Threat Research - Cisco Blogs
Blog — PlanetScale
Blog — PlanetScale
S
Secure Thoughts
博客园 - 三生石上(FineUI控件)
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
K
Kaspersky official blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Cisco Talos Blog
Cisco Talos Blog
H
Help Net Security
博客园 - 叶小钗
爱范儿
爱范儿
GbyAI
GbyAI
I
Intezer
M
MIT News - Artificial intelligence
Latest news
Latest news
Schneier on Security
Schneier on Security
T
Tor Project blog
Simon Willison's Weblog
Simon Willison's Weblog
I
InfoQ
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
C
CXSECURITY Database RSS Feed - CXSecurity.com
罗磊的独立博客
N
News and Events Feed by Topic
T
The Blog of Author Tim Ferriss
V2EX - 技术
V2EX - 技术
B
Blog
T
Tailwind CSS Blog
N
Netflix TechBlog - Medium
Security Latest
Security Latest
V
V2EX
F
Fortinet All Blogs
Forbes - Security
Forbes - Security
Application and Cybersecurity Blog
Application and Cybersecurity Blog
The Hacker News
The Hacker News
Scott Helme
Scott Helme
P
Privacy International News Feed
P
Palo Alto Networks Blog
H
Heimdal Security Blog
C
Cisco Blogs
T
The Exploit Database - CXSecurity.com
博客园 - Franky
酷 壳 – CoolShell
酷 壳 – CoolShell
G
Google Developers Blog
W
WeLiveSecurity
L
LINUX DO - 最新话题

博客园 - -Enchant

Linux上搭建Asp.net MVC3环境(CentOS + Nginx + Mono) 《单例模式》你需要注意的问题 系统框架整理 Extjs prompt 显示密码框 Python网页抓取、模拟登录 单点登录(SSO)的一点思考 Jquery以JSON方式调用WebService 关于抓取百度搜索内容 iPhone开发环境搭建(备忘) SMTP/POP3命令简介(转) C/S模式下 简单的定时任务功能 Asp.net MVC2学习笔记索引 Oracle 调优 Oracle常见错误 @OutputCache指令参数 关于ACL权限控制【ASP.NET MVC2】 c#递归生成XML ASP.NET MVC2 Ajax返回JSON 引用类型的对象复制(浅复制和深复制)
WCF初探
-Enchant · 2010-09-13 · via 博客园 - -Enchant

最近在公司没什么事,就 打算看看 WCF方面的知识,当然肯定是要自己动手操作的啦。

WCF给我第一个感觉就是配置起来有点麻烦,而且稍微没配置好就导致不能访问(还是WebService好啊。。哈哈)。不过 wcf既然是

整合了 .net remoting/webservice 等通讯技术,配置麻烦那也是应该的了。。。

在网上搜索了一些文章看了以后,大概知道 配置文件中的 ABC(a:address b:binding c:contract)。

下面根据vs2010的模板新建了第一个wcf的程序,大部分我们使用wcf估计是用web来调用,所以F5以后,就迫不及待的在地址栏上向调用 webservice一样,

结果傻眼了,调用方法没反映的嘛。。。晕,咋回事啊。。。原来这就需要配置啦,配置不同的调用方法。。

1、首先在 IService1.cs中的方法上加上 [WebGet] 属性(该属性是在 System.ServiceModel.Web 下,所以需要引用 System.ServiceModel.Web这个dll的)

[WebGet]
string GetData(int value);

2、修改web.config 配置文件中

  a、将默认的 第一个 endpoint 中的 binding 中的值改成 "webHttpBinding"

      b、在behaviors中定义一个 behavior 起名字:wb 

<behaviors>
<endpointBehaviors>
<behavior name="wb">
<webHttp/>
</behavior>
</endpointBehaviors>

<serviceBehaviors>
<behavior name="WcfService2.Service1Behavior">
<!-- 为避免泄漏元数据信息,请在部署前将以下值设置为 false 并删除上面的元数据终结点 -->
<serviceMetadata httpGetEnabled="True" httpsGetUrl=""/>
<!-- 要接收故障异常详细信息以进行调试,请将以下值设置为 true。在部署前设置为 false 以避免泄漏异常信息 -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior></serviceBehaviors>
</behaviors>

      c、再将a 中的 endpoint 中 添加 behaviorConfiguration="wb"属性

<endpoint address="" binding="webHttpBinding" contract="WcfService2.IService1" behaviorConfiguration="wb">

这样 F5以后,再在浏览器上 执行 http://localhost:4974/Service1.svc/GetData

可以看到 <string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">You entered: 0</string>

执行成功了啦

注:带参数http://localhost:4974/Service1.svc/GetData?value=123