无法通过主机名访问WCF Rest服务

时间:2014-03-05 15:49:47

标签: c# .net wcf rest

我有一个托管在Windows服务中的WCF Rest服务。当我通过IP地址访问它时它非常完美,例如:

http://12.34.456.78:31333

但在尝试通过主机名访问时返回400错误,例如:

http://myserver:31333

我已经开启了跟踪,但是没有给我任何信息。我的配置如下。有谁知道这里发生了什么?

<system.serviceModel>
    <services>
        <service name="MyApp.MyService" behaviorConfiguration="RestBehavior">
            <endpoint address="http://myserver:31333" binding="webHttpBinding" contract="MyApp.IMyService" behaviorConfiguration="MyServiceEndpointBehavior" bindingConfiguration="RestWebHttpBinding"/>
            <host><baseAddresses><add baseAddress="http://myserver:31333"/></baseAddresses></host>
        </service>
    </services>
    <behaviors>
        <endpointBehaviors>
            <behavior name="MyServiceEndpointBehavior">
                <webHttp/>
            </behavior>
        </endpointBehaviors>
        <serviceBehaviors>
            <behavior name="RestBehavior">
                <serviceMetadata httpsGetEnabled="true"/>
                <serviceDebug includeExceptionDetailInFaults="true"/>
                <serviceCredentials>
                    <windowsAuthentication allowAnonymousLogons="false" includeWindowsGroups="true"/>
                </serviceCredentials>
                <serviceThrottling maxConcurrentCalls="1024" maxConcurrentInstances="1024" maxConcurrentSessions="1024"/>
            </behavior>
            <behavior name="">
                <serviceMetadata httpGetEnabled="true"/>
                <serviceDebug includeExceptionDetailInFaults="false"/>
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <bindings>
        <webHttpBinding>
            <binding name="RestWebHttpBinding">
                <security mode="TransportCredentialOnly">
                    <transport clientCredentialType="Windows" proxyCredentialType="Windows"/>
                </security>
            </binding>
        </webHttpBinding>
    </bindings>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="True" aspNetCompatibilityEnabled="True"/>
</system.serviceModel>

编辑:

当我将clientCredentialType更改为“Ntlm”时,它似乎与Internet Explorer一起使用。当然,这不是我想要的,因为我的客户端依赖于Windows身份验证。

0 个答案:

没有答案