【发布时间】:2010-10-06 21:14:24
【问题描述】:
我正在将现有服务从 HTTP (Dev/UAT) 迁移到 HTTPS (Production),但我遇到了配置问题。这是我的 web.config 的 system.serviceModel 部分:
<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 都试过了,结果是一样的:
- 我可以使用
http://server.domain.com/MyService.svc从我的 SOAP 客户端调用服务 - 我可以使用
https://server.domain.com/MyService.svc从浏览器中访问该服务 - 我无法使用
https://server.domain.com/MyService.svc从我的 SOAP 客户端调用服务 - 使用404: not found时调用总是出错。
我的 https 站点已使用公司域上的 CA 颁发的证书进行了认证,并且我已验证我已在我发出呼叫的系统上的 Trusted Root Certification Authorities 中安装了该 CA 的证书。
相关客户端代码:
Service service = new Service();
service.Url = "http://server.domain.com/MyService.svc";
//service.Url = "https://server.domain.com/MyService.svc";
service.WebMethodCall();
编辑
以下是 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 页面会显示以下链接:
https://boxname.domain.com/MyService.svc?wsdl
而不是预期
https://server.domain.com/MyService.svc?wsdl
【问题讨论】:
-
如果您在生产环境中为您的服务生成 WSDL,它是否包含 HTTPS 端口?
-
我将在编辑中添加关于 WSDL 的注释
-
这是预期的,因为您的 serviceMetadata 仅启用 httpGet 而不是 httpsGet。此外,您无法获得服务参考,因为您没有公开 mex 端点。当您通过 HTTP 访问 WSDL 时,重要的是它的内容——尤其是描述服务和端口的最后部分。