zoukankan      html  css  js  c++  java
  • wcf

    1.http://www.cnblogs.com/smiler/p/3486841.html

    2.wcf通过webget访问注意事项:

    .NET 3.5以后,WCF中提供了WebGet的方式,允许通过url的形式进行Web 服务的访问。在以前的代码中,写过多次类似的例子,但总是忘记如何配置,现在将设置步骤记录如下:

    1. endpoint通讯协议设置成  webHttpBinding
    2. endpoint的行为设置成 <webHttp />
    3. 在接口上加入 WebGet 的Attributes

    示例代码如下: web.config文件的配置

    <system.serviceModel>
    <services>
    <service name="Services.ShowerService">
    <endpoint binding="webHttpBinding" behaviorConfiguration="WebBehavior" contract="Services.IShowerService"/>
    </service>
    </services>
    <behaviors>
    <endpointBehaviors>
    <behavior name="WebBehavior">
    <webHttp />
    </behavior>
    </endpointBehaviors>
    <serviceBehaviors>
    <behavior name="">
    <serviceMetadata httpGetEnabled="true"/>
    <serviceDebug includeExceptionDetailInFaults="false"/>
    </behavior>
    </serviceBehaviors>
    </behaviors>
    </system.serviceModel>

      WCF接口的设置,这里加入了对URI模板(UriTemplate)和JSON(WebMessageFormat.Json)的支持:

    namespace Services
    {
        [ServiceContract]
        publicinterface ShowerService
        {
            [OperationContract]
            [WebGet(UriTemplate="/Hello/{name}", RequestFormat=WebMessageFormat.Json, ResponseFormat=WebMessageFormat.Json)]
            string Hello(string name);
        }
  • 相关阅读:
    28图结构的类实现
    27图的拓扑排序
    26最短路径之Floyd算法
    25最短路径之Dijkstra算法
    24最小生成树之Prim算法
    23最小生成树之Kruskal算法
    22-1图的遍历的源代码
    22图的遍历
    21图结构的基本概念
    20树结构的类实现
  • 原文地址:https://www.cnblogs.com/kaiwanlin/p/3490549.html
Copyright © 2011-2022 走看看