【问题标题】:WCF Configuration for Windows authentication and jQuery用于 Windows 身份验证和 jQuery 的 WCF 配置
【发布时间】:2011-09-21 20:31:38
【问题描述】:

我有一个使用 Windows 身份验证的 ASP.NET MVC 应用程序。我希望该应用程序调用驻留在同一应用程序中的 WCF 服务。但是,我似乎无法为这个应用程序获取配置。 ASP.NET MVC 和 WCF 服务都驻留在同一个项目中。这是我到目前为止的配置:

<system.serviceModel>
    <behaviors>
        <serviceBehaviors>
            <behavior>
                <serviceDebug includeExceptionDetailInFaults="true" />
                <serviceMetadata httpGetEnabled="true" />
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
    <bindings>
        <basicHttpBinding>
            <binding>
                <security mode="TransportCredentialOnly" >
                    <transport clientCredentialType="Windows" proxyCredentialType="Windows" />
                </security>
            </binding>
        </basicHttpBinding>
    </bindings>
    <services>
        <service name="DashboardService">
            <endpoint address="" binding="basicHttpBinding" contract="MyApplication.Services.ICustomService" />
        </service>
    </services>
    <client>
        <endpoint address="" binding="basicHttpBinding" contract="MyApplication.Services.ICustomService" />
    </client>
</system.serviceModel>

我尝试在不同的 ASP.NET 应用程序中使用服务引用连接到 WCF 服务,该方法工作正常并且我可以返回正确的数据。

但是,使用此配置,当我访问 http://domain/myservice.svc/method 时,我收到 400, Bad Request。但是,http://domain/myservice.svchttp://domain/myservice.svc?wsdl 都可以正常工作。

似乎我忽略了 WCF 配置中的某些内容。

感谢您提供任何帮助。

【问题讨论】:

    标签: jquery wcf iis wcf-binding windows-authentication


    【解决方案1】:

    我能够像这样更改我的配置以使用 webHttpBinding:

    <system.serviceModel>
    <behaviors>
        <serviceBehaviors>
            <behavior>
                <serviceMetadata httpGetEnabled="true"/>
                <serviceDebug includeExceptionDetailInFaults="true"/>
            </behavior>
        </serviceBehaviors>
        <endpointBehaviors>
            <behavior name="RestEndpoint">
                <webHttp/>
            </behavior>
        </endpointBehaviors>
    </behaviors>
    <bindings>
        <webHttpBinding>
            <binding name ="WindowsRestBinding">
                <security mode ="TransportCredentialOnly">
                    <transport clientCredentialType ="Windows"/>
                </security>
            </binding>
        </webHttpBinding>
    </bindings>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
    <services>
        <service name="MyApplication.Services.CustomService">
            <endpoint address="" binding="webHttpBinding" bindingConfiguration="WindowsRestBinding" contract="MyApplication.Services.ICustomService" behaviorConfiguration="RestEndpoint" />
        </service>
    </services>
    

    【讨论】:

    【解决方案2】:

    试试

    <security mode="Transport" >
    

    而不是

    <security mode="TransportCredentialOnly" >
    

    【讨论】:

    • 当我这样做时,我收到“找不到与具有绑定 BasicHttpBinding 的端点的方案 https 匹配的基地址。注册的基地址方案是 [http]。”
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-22
    相关资源
    最近更新 更多