隐藏我的WCF服务? [英] Hiding my WCF service?

查看:135
本文介绍了隐藏我的WCF服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在IIS6上托管了WCF服务,并且正在使用.net Framework 3.5.我拥有的网站位于公共领域,我的意思是任何人都可以从任何地方访问.

I have a WCF service hosted on IIS6 and I am using .net framework 3.5. The site I have is on public domain I mean anybody can access from anywhere.

我的问题是,有没有办法隐藏我的WCF服务?我可以轻松查看页面的源代码,或者确切知道页面后面的服务路径...

My question is, is there a way to hide my WCF service? I can easily view source my page or know exactly the the path of my service behind the page...

http://hostname.MyServiceName.svc?wsdl,如何隐藏它?

推荐答案

与David达成共识,即模糊"您的服务还不到解决方案的一半,您当然可以关闭

Agreeing with David that just "obscuring" your service is less than half the solution, you can of course turn off

  • 服务元数据
  • WSDL文件的http可用性

要做的事,请确保您的<service>标签未引用包含<serviceMetadata>标签的<serviceBehavior>.

Do to do, make sure your <service> tag isn't referencing a <serviceBehavior> that includes the <serviceMetadata> tag.

因此,该公开服务元数据(包括基于HTTP的WSDL):

So this will expose service metadata (including WSDL over HTTP):

<behaviors>
   <serviceBehaviors>
      <behavior name="default">
         <serviceMetadata httpGetEnabled="True" />
         <serviceDebug includeExceptionDetailInFaults="True" />
      </behavior>
</serviceBehaviors>
<behaviors>
<services>
   <service name="IYourService" behaviorConfiguration="default">
      ...
   </service>
</services>

虽然这将不公开任何服务元数据(请注意删除<serviceMetadata>标签):

while this will not expose any service metadata (observe the removal of the <serviceMetadata> tag):

<behaviors>
   <serviceBehaviors>
      <behavior name="nometadata">
         <serviceDebug includeExceptionDetailInFaults="True" />
      </behavior>
</serviceBehaviors>
<behaviors>
<services>
   <service name="IYourService" behaviorConfiguration="nometadata">
      ...
   </service>
</services>

在删除任何服务元数据时,您将无法再在Visual Studio(或任何其他开发系统中的等效项)中执行Add Service Reference-该服务只会告诉您可用的内容-您必须知道其他方式.

When removing any service metadata, you won't be able to do Add Service Reference from within Visual Studio (or the equivalent thereof for any of the other development systems) anymore - the service just won't tell you what is available - you have to know some other way.

这篇关于隐藏我的WCF服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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