/// 为了支持多个参数,还需要设置BodyStyle为WrappedRequest。
有多种url形式: --/UserNameEnable?f={UserName}
--/UserNameEnable?name={UserName}&pwd={pwd}
或者: 多个参数 UriTemplate=/Login/{name}/{pwd}
第二个参数选填UriTemplate=/Login/{name}/{*pwd}
第二个参数默认值UriTemplate=/Login/{name}/{pwd=123456}
[OperationContract]
[WebGet(UriTemplate = "/GetData/{UserName}",
ResponseFormat = WebMessageFormat.Json,
RequestFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.WrappedRequest)]
Student GetData(string UserName);
Config配置:
1、 <service name="MT4_CRM.WcfService.UserMoblie">
<endpoint address="" behaviorConfiguration="httpBehavior" binding="webHttpBinding" bindingConfiguration="basicTransport" contract="MT4_CRM.WcfService.Interface.IUserMoblie"/> <!--提供WebGet服务用-->
<endpoint address="Wcf" binding="basicHttpBinding" contract="MT4_CRM.WcfService.Interface.IUserMoblie"/>
<!--提供WCF服务 , 注意address='Wcf',为了区分开与WebGet的地址,添加引用之后会自动加上的-->
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex"/>
<!--元数据-->
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/Service/" />
</baseAddresses>
</host>
</service>
2、
<behaviors>
<endpointBehaviors>
<behavior name="httpBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
</behavior>
3、
<bindings>
<webHttpBinding>
<binding name="basicTransport"/>
</webHttpBinding>
</bindings>
web调用地址:http://localhost:8733/Service/GetData/张三