我部署了一个.NET 4.5站点,该站点具有MVC部分和WCF部分。 WCF托管在IIS中,它是MVC应用程序的子应用程序/子站点。
我遇到的问题是,当MVC调用WCF时,我无法使HTTPS正常工作。 HTTP可以使用,但是一旦添加HTTPS配置,它就会停止工作。
这是我的配置: MVC:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IApplicationContract" >
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://mysiteaddress.com/wcf/MyService.svc/Application"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IApplicationContract"
contract="MyServiceReference.IApplicationContract" name="BasicHttpBinding_IApplicationContract" />
</client>
</system.serviceModel>
WCF:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="basicHttpStreaming" maxReceivedMessageSize="67108864" transferMode="Streamed">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<endpoint address="Application" binding="basicHttpBinding" contract="MyService.Contract.IApplicationContract" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyServicebehavior">
<serviceDebug includeExceptionDetailInFaults="True" />
<serviceMetadata httpGetEnabled="True" httpsGetEnabled="True" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
我收到一条错误消息:
“ EndpointNotFoundException:在https://mysiteaddress.com/wcf/MyService.svc/Application上没有侦听端点可以接受消息的消息。这通常是由于地址或SOAP操作不正确引起的。有关更多详细信息,请参阅InnerException(如果存在)。”
如果在MVC配置中将端点地址更改为“ http://localhost/wcf/MyService.svc/Application”并删除该元素,然后在WCF中删除,换句话说,删除所有HTTPS设置,则一切正常!
使用HTTPs设置之前,我遇到了一个安全配置错误,在添加了启用TLS 1.2的代码后,该错误消失了,因为默认情况下未在.NET 4.5上启用它。
有人知道我在这里想念的吗? IIS具有绑定功能,并且MVC站点可以在HTTP中完美运行,只是在尝试调用WCF时会发生错误。
答案 0 :(得分:0)
显然,对于WCF配置,在HTTP中,如果您在basicHttpBinding元素中指定了多个绑定,然后在services部分中省略了services / service / endpoint / @ bindingConfiguration属性,它将很好地工作。但是,在HTTPS中,这将为您提供404。因此请记住始终向端点添加bindingConfiguration属性。