开发者

Why do i need both mex endpoint and httpGetEnable?

I was wondering why do i need to declare this:

 <serviceMetadata httpGetEnabled="true" />

and also this

<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />

If i use only the first one - it is working via browser. so why do i need the second one ?

Can you give me example please for the 开发者_如何学Pythonsituation which i'll have to use the latter ?


You need to

  • enable the service to publish metadata at all (that's the serviceMetadata behavior) - but you don't need the httpGetEnabled - that's optional

  • have a place (endpoint) where an inquiring client can go grab that service metadata - that's the MEX endpoint. This is for a machine-readable format of the metadata - one that Visual Studio or svcutil can use to create a client. It's not intended for human consumption


This seems to be useful in the following situation...

<system.serviceModel>
    <services>
        <service name="WCFService.Service" behaviorConfiguration="ServiceBehavior">
            <host>
                <baseAddresses>
                    <add baseAddress="net.tcp://localhost:8080/WCFService"/>
                </baseAddresses>
            </host>

            <!-- Net.Tcp EndPoints-->
            <endpoint address=""
              binding="netTcpBinding"
              contract="WCFService.IService" />

            <endpoint address="mex"
              binding="mexTcpBinding"
              contract="IMetadataExchange" />

           </service>
        </services>
        <behaviors>
            <serviceBehaviors>
                <behavior name="ServiceBehavior">
                    <serviceMetadata httpGetEnabled="false" />
                </behavior>
            </serviceBehaviors>
        </behaviors>
</system.serviceModel>

There are no HTTP endpoints defined and you can get to your service in the following ways...

 - Browser: http://localhost/WCFService/Service.svc    
 - svcutil.exe net.tcp://localhost:8080/WCFService/Service.svc/mex

If you comment out the MEX endpoint then neither will work.

You wonder why the meta data can still be seen in the browser as

a) I don't have a HTTP endpoint and b) I have specifically set ...

<serviceMetadata httpGetEnabled="false" />

The reason for this is that in the advanced settings for the website I had the following defined for Enabled Protocols under Advanced Settings...

http,net.tcp

If you remove http then the metadata cannot be seen in the browser. It would seem that it is in this scenario, a net.tcp enabled only website, that you need the mex endpoint.


MEX endpoints are special endpoints that allow clients to receive the service’s metadata by using SOAP messages instead of http get requests. You can create MEX endpoint that can be accessed through http, https, tcp, and even named pipes.

The response that you will receive when calling a MEX endpoint’s GetMetadata operation will include the content of the WSDL and all the XSD files that are linked to it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜