我有一个使用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,错误请求。但是,http://domain/myservice.svc和http://domain/myservice.svc?wsdl都能正常工作。
好像我在WCF配置中忽略了一些东西。
感谢您提供的任何帮助。
答案 0 :(得分: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>
答案 1 :(得分:0)
尝试
<security mode="Transport" >
而不是
<security mode="TransportCredentialOnly" >