WCF笔记

1、怎样在IIS部署WCF

a、 建立虚拟目录并将路径定位到项目文件夹(提供服务的项目文件夹)

b、 设置所属应用程序池

c、 设置asp.net版本

 

2、UriTemplate

[WebGet(UriTemplate = "{id}")]

public void Get();

访问地址不用加Get,直接

http://127.0.0.1:3721/employees/1


3、使用svc文件直接启动服务

直接运行svc文件,启动服务器

endpoint address=""

设置为空或不设置具体地址

4、默认值: "GET")。请求方式 ("POST" 或 "GET"), 默认为 "GET"。注意:其它 HTTP 请求方法,如 PUT 和 DELETE 也可以使用,但仅部分浏览器支持。

5、对于Web HTTP编程模型来说,服务契约中作为操作的方法无须应用OperationContractAttribute特性,只需要根据需要应用WebGetAttribute与WebInvokeAttribute特性即可

6、Bare,所以作为请求消息和回复消息的主体仅仅是Employee对象被序列化后生成的XML

7、wcf reset 设置返回类型
设置ResponseFormat格式,数据就会自动按照相应格式返回
image

8、调用Wcf Web服务注意事项

新增服务后,配置文件会添加下列节。可通过修改value值修改服务地址

 <appSettings>
  <add key="org.gs1cn.ws2.anccService" value="http://ws2.gs1cn.org/anccService.asmx"/>
  </appSettings>
9、wcf和wcf rest 区别

HTTP without an additional messaging layer such as SOAP or session tracking via HTTP cookies. A RESTFul web service is a simple web service implemented using HTTP and the principles of RESTover HTTP without an additional messaging layer such as SOAP or session tracking via HTTP cookies $(document).ready

原文地址:https://www.cnblogs.com/gossip/p/2355512.html