WCF 服务 GET、POST 请求接口的配置
一、接口
1,GET 配置
[OperationContract]
[WebGet(UriTemplate = "/GetUser/{data}")]
string GetUser (string data);
2,POST 配置
[OperationContract]
[WebInvoke(Method = "POST",
BodyStyle =
WebMessageBodyStyle.WrappedRequest)]
string AddUser(string data);
data 和返回值一般为 json 字符串。
二、配置文件
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<diagnostics performanceCounters="All"/>
<services>
<service
name="RDIFramework.ServiceAdapter.POSService">
<endpoint
address="http://localhost:8000/POSService"
binding="webHttpBinding"
contract="RDIFramework.IService.IPOSService">
</endpoint>
<endpoint
address="http://localhost:8000/POSService/mex"
binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<serviceHostingEnvironment
aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true" />
评论3