我新创建了一个 WCF,当我尝试从浏览器中点击 url 时,我面临 400 bad req 错误。
我的服务合同看起来像
[OperationContract]
[WebInvoke(Method = "GET", UriTemplate = "GetUsers")]
string GetUsers();
我已经在 webconfig 中输入了
<serviceMetadata httpGetEnabled="true"/>
我在浏览器中点击的网址是
http://localhost:51561/AceWebService.svc/GetUsers
这是webconfig的一部分:
<system.serviceModel>
<services>
<service name="AceWebService.AceWebService" behaviorConfiguration="AceWebService.AceWebServiceBehavior">
<!-- Service Endpoints -->
<endpoint address="" binding="wsHttpBinding" contract="AceWebService.IAceWebService">
<!--
Upon deployment, the following identity element should be removed or replaced to reflect the
identity under which the deployed service runs. If removed, WCF will infer an appropriate identity
automatically.
-->
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="AceWebService.AceWebServiceBehavior">
<!-- 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="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
参考了stackoverflow中所有可用的问题..没有得到任何帮助..请提出更改建议。
谢谢