通过负载均衡器通过 IIS 的 WCF 报告错误的基地址
我正在尝试通过负载平衡器在 IIS 6 上通过 SSL 启动 WCF 服务。我最初的问题是一个明显且经过充分讨论的问题 - WSDL 页面上显示的地址指向 https://SERVERNAME/ WebServices/mydomainws.svc 而不是 www.mydomain.com。解决这个问题的方法是在IIS中添加一个主机头值。我这样做了并且它起作用了......有点。现在,在浏览器中查看 wsdl 时,我会得到 http://www.mydomain.com/WebServices/mydomainws.svc 。如果我单击该链接(非 ssl 链接),我会得到一个再次引用服务器名称的服务定义。
下一个经常推荐的补救措施是使用 WCF Extras,它提供了一个允许您指定基址的扩展。但设置该配置条目仅更新了soap12:地址。 EndPointReference 地址仍使用机器名称。
总结一下:在 Web 浏览器中查看的 WSDL https://www.mydomain.com/WebServices/mydomainws .svc:http://www.mydomain.com/WebServices/mydomainws.scv
单击上面的链接会将我带到一个实际的 wsdl 文件,其中包含以下服务条目:
<强> <强> https://ServerName/WebServices/mydomainws.svc
我的服务器配置文件具有以下 serviceModel 条目:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="TransportSecurity">
<security mode="Transport">
<message clientCredentialType="None"/>
<transport clientCredentialType="None"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="mydomain.ws.mydomainws" behaviorConfiguration="mydomainwsBehavior">
<!-- Service Endpoints -->
<endpoint address="" **behaviorConfiguration="CorrectEndPoint"** binding="wsHttpBinding" bindingConfiguration="TransportSecurity" contract="mydomain.ws.Imydomainws"/>
<endpoint address="mex" **behaviorConfiguration="CorrectEndPoint"** binding="mexHttpsBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="mydomainwsBehavior">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true" />
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
**<behavior name="CorrectEndPoint">
<wsdlExtensions location="https://www.mydomain.com/WebServices/mydomainws.svc" singleFile="true"/>
</behavior>**
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<extensions>
<behaviorExtensions>
<add name="wsdlExtensions" type="WCFExtras.Wsdl.WsdlExtensionsConfig, WCFExtras, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/>
</behaviorExtensions>
</extensions>
</system.serviceModel>
任何人都可以指出我正确的方向吗?
谢谢, 乔治
I'm trying to launch a WCF service over SSL on IIS 6 through a load balancer. My initial problem was an obvious and pretty well discussed one - the address shown on the WSDL page pointed to https://SERVERNAME/WebServices/mydomainws.svc instead of www.mydomain.com. The answer to this problem is to add a host header value in IIS. I did that and it worked... sort of. I now get http://www.mydomain.com/WebServices/mydomainws.svc when viewing the wsdl in a browser. If I click on that link (the non-ssl link) I get a service definition that again references the server name.
The next oft recommended remedy is to use WCF Extras which provides an extension that allows you to specify a base address. But setting that config entry only updated the soap12:address. The EndPointReference address is still using the machine name.
To summarize: WSDL as viewed in web browser at https://www.mydomain.com/WebServices/mydomainws.svc: http://www.mydomain.com/WebServices/mydomainws.scv
Clicking the above link brings me to an actual wsdl file with the following service entry:
https://ServerName/WebServices/mydomainws.svc
My server config file has the following serviceModel entries:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="TransportSecurity">
<security mode="Transport">
<message clientCredentialType="None"/>
<transport clientCredentialType="None"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="mydomain.ws.mydomainws" behaviorConfiguration="mydomainwsBehavior">
<!-- Service Endpoints -->
<endpoint address="" **behaviorConfiguration="CorrectEndPoint"** binding="wsHttpBinding" bindingConfiguration="TransportSecurity" contract="mydomain.ws.Imydomainws"/>
<endpoint address="mex" **behaviorConfiguration="CorrectEndPoint"** binding="mexHttpsBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="mydomainwsBehavior">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true" />
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
**<behavior name="CorrectEndPoint">
<wsdlExtensions location="https://www.mydomain.com/WebServices/mydomainws.svc" singleFile="true"/>
</behavior>**
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<extensions>
<behaviorExtensions>
<add name="wsdlExtensions" type="WCFExtras.Wsdl.WsdlExtensionsConfig, WCFExtras, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/>
</behaviorExtensions>
</extensions>
</system.serviceModel>
Can anyone point me in the right direction?
Thanks,
George
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这应该通过新行为 useRequestHeadersForMetadataAddress 来处理。尝试将此行为添加到您的服务行为中:
此行为在 WCF 4.0 中可用,并且应该作为 WCF 3.x 的 KB 提供。
This should be handeled by new behavior useRequestHeadersForMetadataAddress. Try to add this to your service behavior:
This behavior is availabel in WCF 4.0 and should be available as KB for WCF 3.x.