我打算发布我的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,它会起作用,如果我将它带回来失败......您之前如何体验过这一点?有任何想法吗? –