Why do i need both mex endpoint and httpGetEnable?

前端 未结 3 845
死守一世寂寞
死守一世寂寞 2020-12-08 15:13

I was wondering why do i need to declare this:

 

and also this



        
相关标签:
3条回答
  • 2020-12-08 15:19

    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 讨论(0)
  • 2020-12-08 15:23

    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

    0 讨论(0)
  • 2020-12-08 15:30

    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.

    0 讨论(0)
提交回复
热议问题