我打算髮布我的Web服務,以便它可以在外部網絡上使用。問題的關鍵在於Web管理員不希望將此Web服務設爲外部,而是希望我圍繞它來包裝代理並使代理處於外部。我不喜歡代理部分,因爲它不必維護服務和代理上的版本。我想知道如果使用外部網絡(URL)訪問web服務以使用SSL並請求身份驗證,但是如果您在內部網絡(URL)中使用它以不請求身份驗證或SSL,是否有簡單的方法來執行此操作。我試過在webconfig中有兩個端點配置,一個安全,一個不安全,但問題是當你使用web服務時,綁定顯示和客戶端可以選擇一個或兩者。如果任何人做了這種不同的方式,或者以不同的方式讓我知道,通常我會採取一種方法,要麼是所有安全方法,要麼是所有非安全方法,但取決於網絡方面並不相同非常感謝:)面向內部和外部客戶端的WCF安全性
1
A
回答
1
你會很高興知道,WCF已經內置支持你的'代理'。它被稱爲路由服務並在WCF 4.0和更高版本中可用。
您可以對其進行配置,以將特定服務合同的Internet呼叫路由到在Intranet中運行的WCF服務。它甚至可以轉換綁定,以便使用TCP綁定的內部服務可以由外部客戶使用可以穿過防火牆的HTTP綁定來調用。
它只需要知道哪些合約路由到哪裏。因此,當您的合同更改時,無需更新...
請參閱here以瞭解更多信息。
EDITED:以下示例system.serviceModel
節點允許客戶端向路由服務添加服務引用。訣竅是讓路由服務將其本身作爲其路由到的服務。請參閱serviceActivations
節點。請注意,這樣就不需要有.svc文件。
接下來我們定義兩個端點過濾器,將服務的請求重定向到路由服務,並將mex端點的請求(顯示元數據)重定向到路由服務的mex端點。請參閱filters
節點。
最後,我們明確地禁止通過http暴露路由服務本身的元數據,強制客戶端使用mex(我們正在路由)進行發現。請參閱serviceBehaviors
節點。
再次編輯:爲MEX大小限制添加解決方案
<system.serviceModel>
<serviceHostingEnvironment>
<serviceActivations>
<!--Lets the routing service impose himself as Service.svc (No .SVC file is needed!!!) -->
<add service="System.ServiceModel.Routing.RoutingService" relativeAddress="Service.svc" />
</serviceActivations>
</serviceHostingEnvironment>
<bindings>
<wsHttpBinding>
<!-- a mexHttpBinding is in fact a wsHttpBinding with security turned off -->
<binding name="mexBinding" maxReceivedMessageSize="5000000">
<security mode="None"/>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior >
<!-- Use the filter table with the name 'Filters' defined below -->
<routing routeOnHeadersOnly="false" filterTableName="Filters"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<!-- Disable exposing metadata for this routing service to force discovery using mex -->
<serviceMetadata httpGetEnabled="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<routing>
<filters>
<!-- Declare a routing filter that filters on endpoint Service.svc -->
<filter name="WcfServiceFilter" filterType="EndpointAddress" filterData="http://localhost/ServiceRouter/Service.svc" />
<!-- Declare a routing filter that filters on mex endpoint of Service.svc -->
<filter name="WcfServiceFilter.mex" filterType="EndpointAddress" filterData="http://localhost/ServiceRouter/Service.svc/mex"/>
</filters>
<filterTables>
<!-- Declare the routing table to use -->
<filterTable name="Filters">
<!-- requests that match the WcfServiceFilter (declared above) should be routed to the client endpoint WcfService -->
<add filterName="WcfServiceFilter" endpointName="WcfService"/>
<!-- requests that match the WcfServiceFilter.mex (declared above) should be routed to the client endpoint WcfService.mex -->
<add filterName="WcfServiceFilter.mex" endpointName="WcfService.mex"/>
</filterTable>
</filterTables>
</routing>
<services>
<!-- Declare our service instance and the endpoints it listens on -->
<service name="System.ServiceModel.Routing.RoutingService">
<!-- Declare the endpoints we listen on -->
<endpoint name="WcfService" contract="System.ServiceModel.Routing.IRequestReplyRouter" binding="wsHttpBinding" />
<endpoint name="WcfServiceFilter.mex" address="mex" contract="System.ServiceModel.Routing.IRequestReplyRouter" binding="mexHttpBinding" />
</service>
</services>
<client>
<!-- Define the client endpoint(s) to route messages to -->
<endpoint name="WcfService" address="http://localhost/WcfService/Service.svc" binding="wsHttpBinding" contract="*" />
<endpoint name="WcfService.mex" address="http://localhost/WcfService/Service.svc/mex" binding="wsHttpBinding" bindingConfiguration="mexBinding" contract="*" />
</client>
</system.serviceModel>
相關問題
- 1. 如何使用WCF郵件安全與外部客戶
- 2. 面向外部客戶的Sharepoint站點
- 3. 保護內部和外部用戶的SharePoint安全
- 4. Mosquitto - 內部和外部客戶端配置
- 5. 在webflow內部和外部彈出安全重定向
- 6. 帶桌面客戶端的SaaS。安全性和性能
- 7. 在面向公衆的服務器安全性上的內部WCF服務
- 8. GWT客戶端外部庫
- 9. WCF客戶端和非WCF客戶端
- 10. WCF客戶端安全默認爲Windows
- 11. 客戶端WCF安全問題
- 12. WCF安全 - 客戶端授權
- 13. WCF + Jquery/json消費客戶端安全
- 14. WCF客戶端安全協商註銷
- 15. 在WCF Web服務內部處理WCF Windows服務客戶端
- 16. 使用客戶端IP地址的WCF安全性
- 17. 當客戶端可以使用Javascript時客戶端WCF服務的安全性客戶端
- 18. 確保內部WCF服務的安全
- 19. .NET - 部署WCF客戶端,無需app.config
- 20. WCF:使用分部類覆蓋客戶端的Dispose方法是否安全?
- 21. 添加客戶端iframe的安全性
- 22. WCF消息級別安全性客戶端證書
- 23. 如何設置WCF安全性以要求客戶端證書?
- 24. 內部網絡上的WCF端點安全最佳實踐
- 25. WCF安全的Web,Windows和移動客戶端
- 26. WCF客戶端在外部解決方案時不工作
- 27. 不同b/w內部鎖定,客戶端鎖定和外部鎖定?
- 28. WCF傳輸安全與peertrust和自簽名客戶端證書
- 29. WCF服務(JSON)和Android客戶端 - 信息安全
- 30. WCF服務客戶端訪問內部構件
我看了一下路由服務,並嘗試了一些例子,但它看起來像它使複雜的客戶端使用該服務,因爲你真的不能引用服務,但一個虛擬代理不清除的方法,除非你分別指定wsdl ...我的理解是否正確? –
路由服務是一個透明的代理,所以你的客戶端不需要知道它在那裏。有關如何配置路由服務以公開其服務元數據的詳細信息,請參閱[本主題]中的答案(http://stackoverflow.com/questions/17476156/wcf-how-to-combine-several-services -into-single-wsdl/19890944#19890944) –
真棒......我感謝您的幫助,因爲這是我第一次創建路由服務......我創建了一個示例服務,並能夠通過'代理'。現在,當我嘗試將「代理」鏈接到我們的實際服務時,它給了我一個錯誤。在單步執行代碼的過程中,我發現它對於某些DataContracts存在問題,這些問題沒有任何意義,因爲它們沒有什麼不同尋常的地方。如果我刪除了DataContract,它會起作用,如果我將它帶回來失敗......您之前如何體驗過這一點?有任何想法嗎? –