c# - WCF 中的 WSDL 和 Mex 端点有什么区别

标签 c# wcf wsdl mex

我有几个关于 mex 端点的问题。

  1. 在遗留网络服务中,我们使用 wsdl 创建代理。 WSDL 公开 Web 服务的元数据。在 wcf 中,另一个术语是 mex 端点,它也公开元数据,但 wsdl 在 wcf 中仍然存在。我是 wcf 的新手,我对 wsdl 和 mex 端点之间的区别感到困惑?

  2. httpGetEnabled="false"或 httpGetEnabled="true" 是什么意思?

  3. 如果我设置httpGetEnabled="false" 那么会发生什么?这是否意味着客户端将无法从他们的 IDE 添加服务引用?但是如果我设置httpGetEnabled="false",看到客户端可以添加服务引用。 httpGetEnabled 设置的作用非常令人困惑。

  4. 一个人说

MEX and WSDL are two different schemes to tell potential clients about the structure of your service. So you can choose to either make your service contracts public as (MEX) or WSDL.

如果上面的说法是正确的,那么请告诉我何时使用 MEX 以及何时使用 WSDL?

  1. 如何禁用 mex 并仅通过 WSDL 公开我的服务?

  2. WSDL 支持所有 bidning,如 wshttp、wsdualhttp 或 tcp 等... 如果可能,请详细讨论 wsdl 和 mex。

更新

你说

5. How can I disable mex and expose my service only through WSDL?

Do not specifiy a mex endpoint in your config and use httpGetEnabled.

您的意思是说配置中不应该有与 mex 端点相关的条目,并且 httpgetenable 看起来像下面这样吗?

<serviceMetadata httpGetEnabled="true" httpGetUrl="http://localhost:8080/SampleService?wsdl"/>

你说

A WSDL is generally exposed through http or https get urls that you can't really configure (say for security limitations or for backward compatibility). MEX endpoints expose metadata over configurable endpoints, and can use different types of transports, such as TCP or HTTP, and different types of security mechanisms.

你说 mex 是可配置的,但 wsdl 不是。 mex 是可配置的 是什么意思?请讨论什么样的配置 mex 支持以及如何配置它。

如果我设置 httpGetEnabled="false"那么 WSDL 将无法生成?

最佳答案

1) in legacy web service we create proxy using wsdl. WSDL expose web service meta data. in wcf another term comes that mex endpoint which also expose meta data but wsdl is still live in wcf.i am new in wcf hence i am confusing what is the difference between wsdl & mex endpoint?

这几乎是一回事,但 mex 旨在支持非 HTTP 协议(protocol)和高级配置/安全方案。 WSDL 是遗留方式,MEX 是 WCF 的新改进版本。

2) what is the meaning of httpGetEnabled="false" or httpGetEnabled="true"

即使您没有为您的服务定义 mex 端点,它也会通过 wsdl 通过 defautl url 公开元数据。

3) if i set httpGetEnabled="false" then what will happen? does it mean that client will not be able to add service reference from IDE? but i set httpGetEnabled="false" and saw client can add service reference. so it is very confusing for me that what httpGetEnabled is false or true does ?

仅当启用 httpGetEnabled/httpsGetEnabled 或您在服务配置中定义了 mex 端点时,客户端才能在 VS 中添加引用。最佳实践是在开发环境而不是生产环境中公开元数据。您还可以通过单独的程序集分发服务契约(Contract)并使用 ChannelFactory

4) one guy said :- MEX and WSDL are two different schemes to tell potential clients about the structure of your service. So you can choose to either make your service contracts public as (MEX) or WSDL. if the above statement is true then tell me when to use MEX & when to use WSDL?

WSDL 通常通过 http 或 https 获取您无法真正配置的 url 公开(比如出于安全限制或向后兼容性)。 MEX 端点通过可配置端点公开元数据,并且可以使用不同类型的传输,例如 TCP 或 HTTP,以及不同类型的安全机制。

因此 MEX 更易于配置,而 WSDL 与旧版本客户端和使用 WSDL 的非 .net 客户端的互操作性更高。

5) how could i disable mex and expose my service through only WSDL

不要在配置中指定 mex 端点并使用 httpGetEnabled

6) WSDL support all bidning like wshttp,wsdualhttp or tcp etc...

公开元数据与调用服务完全不同。

更新

re you try to mean that there should be no mex endpoint related entry in config and httpgetenable would look like

是的,您不必指定 mex 端点和 httpGetEnabled。公开元数据只需要一个。不要指定 httpGetUrl,因为这取决于您的托管环境。

you said mex is configurable but wsdl is not. what r u trying to means mex is configurable...please discuss what kind of configuration mex support & how to configure.

MEX 端点是特殊的端点,允许客户端使用 SOAP 消息而不是 http get 请求来接收服务的元数据。您可以创建可通过 http、https、tcp 甚至命名管道访问的 MEX 端点。 HttpGetEnable 允许您通过 HTTP GET 方法公开元数据,通常是服务的地址,后缀为 '?wsdl'

MEX 和 WSDL 都输出几乎相同的东西。

在大多数情况下,不需要 MEX 端点——使用带有 http get 的 WSDL 通常就足够了。

我明白你想了解这部分的意图,但不要在这上面花很多时间:还有很多其他复杂的功能!

关于c# - WCF 中的 WSDL 和 Mex 端点有什么区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21522493/

相关文章:

c# - 如何在单独的线程中将文件保存到硬盘?

c# - 使用单选按钮

c# - WCF 服务的方法返回不同类型的对象?

maven - 将 maven 代码生成转换为 gradle 任务

perl - 使用基于 WSDL 的 SOAP::Lite

.net - 不同子命名空间中的类都出现在 WSDL 的顶层

c# - 自定义控件和必填字段验证器

c# - Entity Framework - 如何检查表是否存在?

c# - WCF - 接收对 http ://xxxxx/Service/的 HTTP 响应时出错

multithreading - WCF Operation.Context 不是线程安全的?