0

有谁知道如何在配置文件中设置 WCF 的身份验证?

例子:

我有 WCF 来接受用户的请求,用户只需要通过下面的 URL 传递变量:

http://localhost/test/username/password/

WCF 可以根据这个来检查是接受还是拒绝请求。

我在配置文件下编写了以下代码,但不知何故它不起作用

4

2 回答 2

0
<services>
  <service behaviorConfiguration="ServiceBehavior" name="Service">
    <endpoint address="" binding="basicHttpBinding"
        name="BasicHttpEndpoint"
        bindingConfiguration=""
        contract="IService">
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding"
       contract="IMetadataExchange" />
  </service>
</services> 
于 2013-09-13T06:00:36.027 回答
0

包括行为规范的示例:

<system.serviceModel>
    <behaviors>
        <endpointBehaviors>
            <behavior name="EndpointAjaxBehaviorName">
                <enableWebScript />
            </behavior>
        </endpointBehaviors>
        <serviceBehaviors>
            <behavior name="ServiceBehaviorName" >
                <serviceMetadata httpGetEnabled="true" />
                <serviceDebug includeExceptionDetailInFaults="true"/>
                <serviceAuthorization impersonateCallerForAllOperations="false" />
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
    <services>
        <service name="ServiceName" 
                    behaviorConfiguration="ServiceBehaviorName">
            <endpoint address="" behaviorConfiguration="EndpointAjaxBehaviorName"
             binding="webHttpBinding" contract="YourServiceOrInterface" />
            <endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
        </service>
    </services>
</system.serviceModel>

如果要使用 Ajax,则需要“enableWebScript”

于 2013-09-13T06:20:56.030 回答