让你的WCF服务支持WebGet属性

看着别人把WCF服务和web请求结合一起用很爽,可是自己怎么也配置不出来(没有用web host),所以研究了一下wcf的binding的配置

  1. endpoint的 binding必须为webHttpBinding.
  2. Endpoint的behavior中要加入webhttp.

示例配置文件如下:

<?xml version="1.0" encoding="utf-8" ?>

<configuration>

<system.web>

<compilation debug="true" />

</system.web>

<!-- When deploying the service library project, the content of the config file must be added to the host's

app.config file. System.Configuration does not support config files for libraries. -->

<system.serviceModel>

<services>

<service name="Services.PlayerService" behaviorConfiguration="bh">

<host>

<baseAddresses>

<add baseAddress = "http://localhost:8731/PlayerService/" />

</baseAddresses>

</host>

<!-- Service Endpoints -->

<!-- Unless fully qualified, address is relative to base address supplied above -->

<endpoint address ="" binding="basicHttpBinding" contract="Contrat.IPlayerService" behaviorConfiguration="web"></endpoint>

<!-- Metadata Endpoints -->

<!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. -->

<!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->

<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>

</service>

</services>

<behaviors>

<endpointBehaviors>

<behavior name="web">

<webHttp/>

</behavior>

</endpointBehaviors>

<serviceBehaviors>

<behavior name="bh">

<!-- To avoid disclosing metadata information,

set the value below to false and remove the metadata endpoint above before deployment -->

<serviceMetadata httpGetEnabled="True"/>

<!-- To receive exception details in faults for debugging purposes,

set the value below to true. Set to false before deployment

to avoid disclosing exception information -->

<serviceDebug includeExceptionDetailInFaults="False" />

 

</behavior>

</serviceBehaviors>

</behaviors>

</system.serviceModel>

</configuration>

转载于:https://www.cnblogs.com/tionase/archive/2008/08/05/1260748.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值