WCF, Metadata and BIGIP - Can I force the correct url for the WSDL items?

前端 未结 5 1104
-上瘾入骨i
-上瘾入骨i 2020-12-31 15:59

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.

The service is fronted by BIGI

5条回答
  •  伪装坚强ぢ
    2020-12-31 16:43

    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. The advertised service endpoint hostname.
    2. Hostname of links to xsd:import'ed schemas that describe the data contract
    3. the http/https problem you describe.

    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).

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

    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.

    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.

    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".

提交回复
热议问题