WCF服务通过https而不是http返回404 [英] WCF service returns 404 over https but not http
问题描述
我正在将现有服务从HTTP(Dev / UAT)迁移到HTTPS(生产),我遇到配置问题。这是我的web.config的system.serviceModel部分:
I'm migrating an existing service from HTTP (Dev/UAT) to HTTPS (Production), and I'm having trouble with the configuration. Here is the system.serviceModel section of my web.config:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="false" />
<services>
<service name="MyService">
<endpoint name="MyEndpoint" address="" binding="wsHttpBinding"
bindingConfiguration="secureBinding" contract="IMyService" />
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="secureBinding">
<security mode="Transport"></security>
</binding>
</wsHttpBinding>
</bindings>
</system.serviceModel>
我已经尝试使用 basicHttpBinding
和 wsHttpBinding
,结果相同:
I've tried this using both basicHttpBinding
and wsHttpBinding
, with the same results:
- 我可以从我的服务中调用该服务SOAP客户端使用
http://server.domain.com/MyService.svc
- 我可以使用<从浏览器点击服务code> https://server.domain.com/MyService.svc
- 我无法使用<$从我的SOAP客户端调用该服务c $ c> https://server.domain.com/MyService.svc - 调用总是错误
404:找不到
。
- I can call the service from my SOAP client using
http://server.domain.com/MyService.svc
- I can hit the service from a browser using
https://server.domain.com/MyService.svc
- I can't call the service from my SOAP client using
https://server.domain.com/MyService.svc
- the call always errors with404: not found
.
我的https网站使用公司域上的CA颁发的证书进行了认证,我已经确认我有CA的我正在拨打电话的系统上安装在受信任的根证书颁发机构
中的证书。
My https site is certified using a certificate that was issued by a CA on the corporate domain, and I've verified that I have that CA's certificate installed in Trusted Root Certification Authorities
on the system from which I'm making the calls.
相关客户代码:
Service service = new Service();
service.Url = "http://server.domain.com/MyService.svc";
//service.Url = "https://server.domain.com/MyService.svc";
service.WebMethodCall();
编辑
以下是WSDL的请求部分:
Here are the requested portions of the WSDL:
<wsdl:types/>
<wsdl:portType name="IMyService"/>
<wsdl:binding name="BasicHttpBinding_IMyService" type="tns:IMyService">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
</wsdl:binding>
<wsdl:service name="MyService">
<wsdl:port name="BasicHttpBinding_IMyService"
binding="tns:BasicHttpBinding_IMyService">
<soap:address location="http://server.domain.com/MyService.svc"/>
</wsdl:port>
</wsdl:service>
编辑
更多信息:
当我将serviceMetadata元素更改为 httpGetEnabled =false
和<$ c时$ c> httpsGetEnabled =true .svc页面显示以下链接:
When I change the serviceMetadata element to have httpGetEnabled="false"
and httpsGetEnabled="true"
the .svc page shows me the following link:
https://boxname.domain.com/MyService.svc?wsdl
而不是预期的
https://server.domain.com/MyService.svc?wsdl
推荐答案
检查web.config中的服务元素名称是否与实现合同的类的完全限定名称相匹配。 / p>
Check that your service element name in the web.config matches the fully qualified named of the class that implements your contract.
<services>
<service name="MyNamespace.MyService">
<endpoint name="MyEndpoint" address="" binding="wsHttpBinding" ...
这篇关于WCF服务通过https而不是http返回404的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!