WCF 服务通过 https 而不是 http 返回 404 [英] WCF service returns 404 over https but not http

查看:29
本文介绍了WCF 服务通过 https 而不是 http 返回 404的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将现有服务从 HTTP(开发/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>

我已经尝试过使用 basicHttpBindingwsHttpBinding,结果相同:

I've tried this using both basicHttpBinding and wsHttpBinding, with the same results:

  • 我可以使用 http://server.domain.com/MyService.svc
  • 从我的 SOAP 客户端调用该服务
  • 我可以使用 https://server.domain.com/MyService.svc
  • 从浏览器点击该服务
  • 我无法使用 https://server.domain.com/MyService.svc 从我的 SOAP 客户端调用该服务 - 调用总是出错,404: not found.
  • 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 with 404: not found.

我的 https 站点已使用公司域上的 CA 颁发的证书进行认证,并且我已验证我已在系统上的 Trusted Root Certification Authorities 中安装了该 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"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 中的服务元素名称是否与实现合同的类的完全限定名称匹配.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆