[英]WCF service web.config tweaks to change the generated wdl
我的wcf服務遵循以下負載平衡結構:
公共(https)-> F5 LB(http)-> node1 / node2。
我在http方案上公開服務,F5 LB負責ssl卸載。 由於我的服務公開為http,因此通過F5 LB生成的wsdl包含基於http的網址,如下所示:
我的LB服務網址:
https://myservice.mydomain.com/service1.svc
生成的服務頁面為:
MyService Service
You have created a service.
To test this service, you will need to create a client and use it to call the service. You can do this using the svcutil.exe tool from the command line with the following syntax:
svcutil.exe http://myservice.mydomain.com/service1.svc?wsdl
You can also access the service description as a single file:
http://myservice.mydomain.com/service1.svc?singleWsdl
如您所見,生成的頁面具有從應用程序節點公開的http網址。 由於F5 LB將服務公開為https,因此其不允許上述http url,並且來自客戶端的請求正在退回。
現在,我們可以調整服務web.config以在http方案上公開該服務,但是將wsdl指向https url,以便從F5 LB的wsdl上方生成的url https和客戶端也將在https上工作,並且來自LB的請求將我的服務處理的http服務?
我從未做過此事,但是像WCF中的大多數事情一樣,可以擴展一些擴展點以覆蓋其默認行為。
聽起來您需要執行的是實現自定義“元數據”端點。 在MSDN上有一系列有關導出自定義元數據的文章。 具體來說,您可以實現一個IWsdlExportExtension
,它使您可以在將WSDL數據發送到客戶端之前對其進行訪問。
看起來這與大多數其他行為擴展都一樣,這意味着您會做類似的事情(再次,我從未做過,但這應該可以使您入門;有關此行為擴展背后的更多詳細信息,請參閱此博客條目 。機制):
IWsdlExportExtension
和IEndpointBehavior
。 例如:
public class LbWsdl : IWsdlExportExtension, IEndpointBehavior
{
public void ExportContract(WsdlExporter exporter, WsdlContractConversionContext context)
{
// Fix WSDL here
}
}
public class LbWsdlExtension : BehaviorExtensionElement
{
public override Type BehaviorType
{
get { return typeof(LbWsdl); }
}
}
<system.serviceModel>
<extensions>
<behaviorExtensions>
<add name="lbWsdl" type="LbWsdlExtensions.LbWsdlExtension,LbWsdlExtension />
</behaviorExtensions>
</extensions>
<behaviors>
<endpointBehaviors>
<behavior name="LoadBalancedBehavior">
<webHttp/>
<lbWsdl />
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
在不完全了解您的配置/環境的情況下,我將建議一些選項來幫助您解決問題:
address
和/或listenUri
) System.ServiceModel.Description.IWsdlExportExtension
來控制呈現的服務元數據 參考文獻:
WCF中的WSDL和Mex端點之間有什么區別
http://blogs.msdn.com/b/saurabs/archive/2012/04/27/http-get-vs-mex-end-point.aspx
http://msdn.microsoft.com/en-us/library/aa717040.aspx
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.