WCF,元数据和BIGIP-是否可以为WSDL项目强制使用正确的URL? [英] WCF, Metadata and BIGIP - Can I force the correct url for the WSDL items?

查看:114
本文介绍了WCF,元数据和BIGIP-是否可以为WSDL项目强制使用正确的URL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在ServerA上托管了WCF服务,该服务器是无直接Internet访问的服务器,并且具有不可Internet路由的IP地址.

We have a WCF service hosted on ServerA which is a server with no-direct Internet access and has a non-Internet routable IP address.

该服务以BIGIP开头,该BIGIP处理SSL加密和解密,并将未加密的请求转发到特定端口上的ServerA(目前它实际上并未进行任何负载平衡,但将来可能会添加).

The service is fronted by BIGIP which handles SSL encryption and decryption and forwards the unencrypted request to ServerA (at the moment it does NOT actually do any load balancing, but that is likely to be added in the future) on a specific port.

这意味着我们的客户将通过 https://www.OurDomain.com/ServiceUrl调用服务并通过BIGIP设备通过 http://SeverA:85/ServiceUrl 进入我们的服务;

What that means is that our clients would be calling the service through https://www.OurDomain.com/ServiceUrl and would get to our service on http://SeverA:85/ServiceUrl through the BIGIP device;

当我们浏览到发布在 https://www.OurDomain.com/ServiceUrl 所有上的WSDL时WSDL中包含的地址基于 http://SeverA:85/ServiceUrl 基址

When we browse to the WSDL published on https://www.OurDomain.com/ServiceUrl all the addresses contained in the WSDL are based on the http://SeverA:85/ServiceUrl base address

我们发现我们可以使用主机头设置来设置域,但是我们的问题是,尽管这将对域进行排序,但是我们仍然会使用错误的方案–它会使用

We figured out that we could use the host headers setting to set the domain, but our problem is that while this would sort out the domain, we would still be using the wrong scheme – it would use http://www.OurDomain.com/ServiceUrl while we need it to be Https.

此外-由于我们在该服务器上托管了其他服务(基于asmx),因此在设置主机标头时遇到了一些问题,因此我们认为我们可以摆脱在服务器上创建另一个站点的麻烦(使用端口82)并在其上设置主机头;现在,除了http/https问题之外,我们还有一个问题,因为WSDL在所有url中都包含端口号,其中BigIP在端口443上工作(对于SSL)

Also – as we have other services (asmx based) hosted on that server we had some issues setting the host headers, and so we thought we could get away with creating another site on the server (using, say, port 82) and set the host header on that; now, on top of the http/https problem we have an issue as the WSDL contains the port number in all the urls, where BigIP works on port 443 (for the SSL)

是否有比实现主机头更灵活的解决方案?理想情况下,我们需要保持灵活性和易维护性.

Is there a more flexible solution than implementing Host Headers? Ideally we need to retain flexibility and ease of supportability.

感谢您的帮助...

推荐答案

这本质上是一个多部分问题,涉及许多离散解决方案以提供完整答案.坐在F5后面本质上有3个问题.

This is essentially a multi-part problem that involves a number of discrete solutions to provide the full answer. Essentially there are 3 problems with sitting behind the F5.

  1. 播发的服务端点主机名.
  2. 描述数据协定的xsd:import架构链接的主机名
  3. 您描述的http/https问题.

更改主机标头可以找到解决方案1和2(可以用主机标头以外的其他方法来实现,但无需在此处进行介绍).数字3有点棘手,需要更多代码(太多代码无法在此处丢弃).

Changing the host headers, as you have found solves 1 and 2 (you can approach this in ways other than host headers, but no need to go into that here). Number 3 is a bit more tricky and requires more code (too much to dump out here).

简短的答案是,您需要编写一个同时实现IContractBehavior和IWsdlExportExtension的ContractBehavior.

The short answer is that you need to write a ContractBehavior that implements both IContractBehavior and IWsdlExportExtension.

您需要实现的重要部分是IWsdlExportExtension.ExportEndpoint.在此方法中,您需要遍历所有WsdlPort扩展,并且当您找到类型为SoapAddressBinding的扩展时,需要用一个包含https协议说明符的新Uri替换SoapAddressBinding.Location属性.您还需要对xsd导入地址和架构链接执行类似的操作.

The important bit you need to implement is the IWsdlExportExtension.ExportEndpoint. Within this method you need to iterate over all the WsdlPort Extensions, and when you find an extension that is of type SoapAddressBinding you need to replace the SoapAddressBinding.Location property with a new Uri that contains the https protocol specifier. You also need to do similar bits for the xsd import addresses and schema links.

如果您的服务也使用WS-Addressing,则需要执行类似的操作来处理它写到wsdl的其他地址.

If your service is also using WS-Addressing You then need to do something similar to handle the additional addresses it writes out to the wsdl.

我最终基于CodePlex上的WsdlExtras项目编写的代码( http://wcfextras. codeplex.com/). WsdlExtras中使用的方法为您可能需要添加到其中的任何其他位提供了一个很好的基础(从内存中,我认为它不涉及WS-Addressing位).您要查看的是覆盖SOAP地址位置URL".

I based the code I ended up writing on the WsdlExtras project available on CodePlex (http://wcfextras.codeplex.com/). The method used in the WsdlExtras provides a great base for any extra bits you may need to add to it (From memory I don't think it dealt with the WS-Addressing bits). The bit you want to look at is the "Override SOAP Address Location URL".

这篇关于WCF,元数据和BIGIP-是否可以为WSDL项目强制使用正确的URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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