none
Error in the svcutil.exe - Cannot obtain Metadata from http://localhost...

    Question

  • I wander in the svcutil.exe - Cannot obtain Metadata from http://localhost...

    Of a com+ I created the service using Integrate - COM+ of the tool Service configuration editor, and the integration generated 2 files web.config and bus_SLZ.ClienteQ.svc. Now I am trying to use the tool svcutil to consume Client, but this giving the mistake below:

    C:\Program Files\Microsoft SDKs\Windows\v6.0\Bin>svcutil.exe http://localhost/vb
    ComSLZ/bus_SLZ.ClienteQ.svc /out:proxy.vb

    Microsoft (R) Service Model Metadata Tool
    [Microsoft (R) Windows (R) Communication Foundation, Version 3.0.4506.30]
    Copyright (c) Microsoft Corporation.  All rights reserved.

    Attempting to download metadata from 'http://localhost/vbComSLZ/bus_SLZ.ClienteQ
    .svc' using WS-Metadata Exchange or DISCO.
    Microsoft (R) Service Model Metadata Tool
    [Microsoft (R) Windows (R) Communication Foundation, Version 3.0.4506.30]
    Copyright (c) Microsoft Corporation.  All rights reserved.

    Error: Cannot obtain Metadata from http://localhost/vbComSLZ/bus_SLZ.ClienteQ.sv
    c

    If this is a Windows (R) Communication Foundation service to which you have acce
    ss, please check that you have enabled metadata publishing at the specified addr
    ess.  For help enabling metadata publishing, please refer to the MSDN documentat
    ion at http://go.microsoft.com/fwlink/?LinkId=65455.


    WS-Metadata Exchange Error
        URI: http://localhost/vbComSLZ/bus_SLZ.ClienteQ.svc

        Metadata contains a reference that cannot be resolved: 'http://localhost/vbC
    omSLZ/bus_SLZ.ClienteQ.svc'.

        The remote server returned an unexpected response: (405) Method not allowed.


        The remote server returned an error: (405) Method Not Allowed.


    HTTP GET Error
        URI: http://localhost/vbComSLZ/bus_SLZ.ClienteQ.svc

        The document at the url http://localhost/vbComSLZ/bus_SLZ.ClienteQ.svc was n
    ot recognized as a known document type.
    The error message from each known type may help you fix the problem:
    - Report from 'DISCO Document' is 'Name cannot begin with the '%' character, hex
    adecimal value 0x25. Line 1, position 2.'.
    - Report from 'WSDL Document' is 'There is an error in XML document (1, 2).'.
      - Name cannot begin with the '%' character, hexadecimal value 0x25. Line 1, po
    sition 2.
    - Report from 'XML Schema' is 'Name cannot begin with the '%' character, hexadec
    imal value 0x25. Line 1, position 2.'.

    If you would like more help, type "svcutil /?"
    ----------------------------------------------------------------

    My Web.Config

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
        <system.serviceModel>
            <behaviors>
                <serviceBehaviors>
                    <behavior name="ComServiceMexBehavior">
                        <serviceMetadata httpGetEnabled="true" />
                        <serviceDebug includeExceptionDetailInFaults="false" />
                    </behavior>
                </serviceBehaviors>
            </behaviors>
            <bindings>
                <wsHttpBinding>
                    <binding name="comNonTransactionalBinding">
                        <reliableSession enabled="true" />
                    </binding>
                    <binding name="comTransactionalBinding" transactionFlow="true">
                        <reliableSession enabled="true" />
                    </binding>
                </wsHttpBinding>
            </bindings>
            <comContracts>
                <comContract contract="{18FC8E17-9E89-4C9D-85EB-13DF6AB66F1E}"
                    name="_ClienteQ" namespace="http://tempuri.org/18FC8E17-9E89-4C9D-85EB-13DF6AB66F1E"
                    requiresSession="true">
                    <exposedMethods>
                        <add exposedMethod="GetDadosClienteByIdCliente" />
                    </exposedMethods>
                </comContract>
            </comContracts>
            <services>
                <service behaviorConfiguration="ComServiceMexBehavior" name="{AA562D1F-92E8-43DD-A0DF-1801B9F65AA0},{9C924239-0E56-4452-9FA6-556DC398A5B3}">
                    <endpoint address="_ClienteQ" binding="wsHttpBinding" bindingConfiguration="comTransactionalBinding"
                        contract="{18FC8E17-9E89-4C9D-85EB-13DF6AB66F1E}" />
                    <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration=""
                        contract="IMetadataExchange" />
                    <host>
                        <baseAddresses>
                            <add baseAddress="http://localhost:80/vbComSLZ/service" />
                        </baseAddresses>
                    </host>
                </service>
            </services>
        </system.serviceModel>
    </configuration>

    ------------------
    COMSVCCONFIG.EXE

    C:\WINDOWS\Microsoft.NET\Framework\v3.0\Windows Communication Foundation>ComSvcC
    onfig.exe /list

    Microsoft (R) COM+ Service Model Integration Configuration Tool
    [Microsoft (R) Windows (R) Communication Foundation, Version 3.0.4506.30]
    Copyright (c) Microsoft Corporation.  All rights reserved.

    Application:ProjetoVBSerializa
         Hosting: Complus
         Config file: C:\Program Files\ComPlus Applications\{aa562d1f-92e8-43dd-a0df
    -1801b9f65aa0}\application.config
         Hosting: was
         Config file: D:\vbComSLZ\web.config
         Component:bus_SLZ.ClienteQ
              Interface:_ClienteQ
                 binding:netTcpBinding
                 bindingConfiguration:comTransactionalBinding
                 address:net.tcp://localhost:8081/vbComSLZ/_ClienteQ
                 binding:netTcpBinding
                 bindingConfiguration:comTransactionalBinding
                 address:http://localhost/vbComSLZ/_ClienteQ
                 binding:wsHttpBinding
                 bindingConfiguration:comTransactionalBinding
                 address:_ClienteQ
              MEX address: net.tcp://localhost:8081/vbComSLZ/mex
              MEX address: http://localhost/vbComSLZ/mex
              MEX address: mex

    Thursday, February 22, 2007 10:52 AM

Answers

  • You need to point it at the proper mex endpoint, which in your case is http://localhost:80/vbComSLZ/service/mex

    The endpoint address is the combination of the base address and the relative endbpoint address, which you can find here (this is true for all endpoints, not just mex):

       <service behaviorConfiguration="ComServiceMexBehavior" name="{AA562D1F-92E8-43DD-A0DF-1801B9F65AA0},{9C924239-0E56-4452-9FA6-556DC398A5B3}">
                    <endpoint address="_ClienteQ" binding="wsHttpBinding" bindingConfiguration="comTransactionalBinding"
                        contract="{18FC8E17-9E89-4C9D-85EB-13DF6AB66F1E}" />
                    <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration=""   <- second part of the address
                        contract="IMetadataExchange" />
                    <host>
                        <baseAddresses>
                            <add baseAddress="http://localhost:80/vbComSLZ/service" />   <- first part of the address
                        </baseAddresses>

    You can check to see if the address is right by putting it in your browser.

    Monday, February 26, 2007 7:42 PM