none
Why is svcutil using HTTP Post method to get a WSDL?

    Question

  • I am getting the following error when trying to generate a proxy class for a service:

    Error: Cannot obtain Metadata from https://server.com/Services/Service1.asmx?WSDL
    
    If this is a Windows (R) Communication Foundation service to which you have access, please
     check that you have enabled metadata publishing at the specified address.  For help enabl
    ing metadata publishing, please refer to the MSDN documentation at http://go.microsoft.com
    /fwlink/?LinkId=65455.
    
    
    WS-Metadata Exchange Error
        URI: https://server.com/Services/Service1.asmx?WSDL
    
        Metadata contains a reference that cannot be resolved: 'https://server.com/Services/Service1.asmx?WSDL'.
    
        An error occurred while receiving the HTTP response to https://server.com/Services/Service1.asmx?WSDL. This could be due to the service endpoint binding not using
     the HTTP protocol. This could also be due to an HTTP request context being aborted by the
     server (possibly due to the service shutting down). See server logs for more details.
    
        The underlying connection was closed: An unexpected error occurred on a receive.
    
        Unable to read data from the transport connection: An established connection was abort
    ed by the software in your host machine.
    
        An established connection was aborted by the software in your host machine
    
    
    HTTP GET Error
        URI: https://server.com/Services/Service1.asmx?WSDL
    
        There was an error downloading 'https://server.com/Services/Service1.asmx?WSDL'.
    
        The request was aborted: Could not create SSL/TLS secure channel.
    
    If you would like more help, type "svcutil /?"
    This is a problem because the error it is saying is wrong.  I am using wireshark to see the request for the WSDL and what it is really doing is making an HTTP Post, not an HTTP Get.  I know the service works because I can hit it with a browser and get the WSDL.  The service also requires client certificates which appears to be working based on the packet trace I see.  I have tried to make svcutil use HTTP Get to get the WSDL but it keeps using the POST method.  I beleive that is the cause of the problem, because with the way I have the service configured, it is not going to return a WSDL from an HTTP Post because it is expecting a message.  It would help to know that the service is not an IIS or Microsoft service.

    Any help is appreciated.  Here is svcutil.exe.config:

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <system.serviceModel>
        <services>
          <service behaviorConfiguration="UseHttpGet" name="MathService">
            <endpoint address="https://server.com/Services/Service1.asmx?WSDL"
              behaviorConfiguration="ClientCertificateBehavior" binding="wsHttpBinding"
              bindingConfiguration="Binding1" contract="MathServiceContract" />
          </service>
        </services>
        <client>
          <endpoint behaviorConfiguration="ClientCertificateBehavior" binding="wsHttpBinding"
            bindingConfiguration="Binding1" contract="IMetadataExchange"
            name="https" />
        </client>
        <bindings>
          <wsHttpBinding>
            <binding name="Binding1">
              <security mode="Transport">
                <transport clientCredentialType="Certificate" />
              </security>
            </binding>
          </wsHttpBinding>
        </bindings>
        <behaviors>
          <endpointBehaviors>
            <behavior name="ClientCertificateBehavior">
              <clientCredentials>
                <clientCertificate findValue="cn_of_my_cert" storeLocation="CurrentUser"
                  storeName="My" x509FindType="FindBySubjectName" />
              </clientCredentials>
            </behavior>
          </endpointBehaviors>
          <serviceBehaviors>
            <behavior name="UseHttpGet">
              <serviceMetadata httpGetEnabled="true" httpGetUrl="https://server.com/Services/Service1.asmx?WSDL"
                httpsGetEnabled="true" httpsGetUrl="https://server.com/Services/Service1.asmx?WSDL" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
      </system.serviceModel>
    </configuration>
    
    Friday, May 01, 2009 10:35 PM

All replies

  • Maybe the problem is related to wsdl:import tag. What is the address in wsdl:import tag of the generated wsdl? If this is the problem, try to use the FlatWsdl extensions (http://blogs.thinktecture.com/cweyer/archive/2007/05/10/414840.aspx).
    Fabio Cozzolino Blogs: http://dotnetside.org/blogs/fabio http://weblogs.asp.net/fabio
    • Proposed as answer by Marco Zhou Monday, May 04, 2009 8:26 AM
    Sunday, May 03, 2009 5:20 PM
  • I don't think the problem is with WSDL import tags because svcutil.exe works when I set the server to not require client certificates.

    Here is the WSDL Import for Schema:

    <wsdl:types>
    −
    <xsd:schema>
    <xsd:import schemaLocation="MathService.asmx.xsd1.xsd" namespace="http://Server.com/WSTests/"/>
    </xsd:schema>
    </wsdl:types>

    Now you would think this is obviously a problem with client certificate authentication, right?  Well, Wireshark has me believing otherwise.  Here is why:

    When I set the server to require client certificate authentication, svcutil.exe actually uses a certificate I have in my personal store and the SSL negotiation succeeds.  Here is the SSL stream from Wireshark:

    POST /WSTests/MathService.asmx?WSDL HTTP/1.1
    
    Content-Type: application/soap+xml; charset=utf-8
    
    Host: server.com
    
    Content-Length: 502
    
    Expect: 100-continue
    
    Connection: Keep-Alive
    
    
    
    HTTP/1.1 100 Continue
    
    X-Note: Gateway Ack
    
    
    
    <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing"><s:Header><a:Action s:mustUnderstand="1">http://schemas.xmlsoap.org/ws/2004/09/transfer/Get</a:Action><a:MessageID>urn:uuid:1b7cacf4-ba3a-481c-b64c-ce9be930fdc5</a:MessageID><a:ReplyTo><a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address></a:ReplyTo><a:To s:mustUnderstand="1">https://server.com/WSTests/MathService.asmx?WSDL</a:To></s:Header><s:Body/></s:Envelope>HTTP/1.0 500 Error
    
    Content-Type: application/soap+xml; charset=utf-8
    
    X-Backside-Transport: FAIL FAIL
    
    Connection: close
    
    
    
    <?xml version='1.0' ?>
    <env:Envelope xmlns:env='http://www.w3.org/2003/05/soap-envelope'>
    <env:Body>
    <env:Fault>
    <env:Code>
    <env:Value>
    env:Receiver</env:Value>
    </env:Code>
    <env:Reason>
    <env:Text xml:lang="en-US">
    Internal Error (from server)
    </env:Text>
    </env:Reason>
    </env:Fault>
    </env:Body>
    </env:Envelope>
    
    I get a soap fault and svcutil throws the error I posted in my first message complaining about SSL/TLS.  But how is it possible to get a soap fault if SSL/TLS failed?  Looking in wireshark, I see the client providing a client certificate, and from experience with this server, I know it would not throw a soap fault if SSL/TLS with mutual auth failed.

    However, if I set client certificate authentication to optional, check this stream:

    POST /WSTests/MathService.asmx?WSDL/mex HTTP/1.1
    
    Content-Type: application/soap+xml; charset=utf-8
    
    Host: Server.com
    
    Content-Length: 506
    
    Expect: 100-continue
    
    Connection: Keep-Alive
    
    
    
    HTTP/1.1 100 Continue
    
    X-Note: Gateway Ack
    
    
    
    HTTP/1.0 500 Error
    
    Content-Type: application/soap+xml; charset=utf-8
    
    X-Backside-Transport: FAIL FAIL
    
    Connection: close
    
    
    
    <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing"><s:Header><a:Action s:mustUnderstand="1">http://schemas.xmlsoap.org/ws/2004/09/transfer/Get</a:Action><a:MessageID>urn:uuid:ebad7b07-f242-413d-90fc-c9daca0ce956</a:MessageID><a:ReplyTo><a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address></a:ReplyTo><a:To s:mustUnderstand="1">https://Server.com/WSTests/MathService.asmx?WSDL/mex</a:To></s:Header><s:Body/></s:Envelope><?xml version='1.0' ?>
    <env:Envelope xmlns:env='http://www.w3.org/2003/05/soap-envelope'>
    <env:Body>
    <env:Fault>
    <env:Code>
    <env:Value>
    env:Receiver</env:Value>
    </env:Code>
    <env:Reason>
    <env:Text xml:lang="en-US">
    Internal Error (from server)
    </env:Text>
    </env:Reason>
    </env:Fault>
    </env:Body>
    </env:Envelope>
    
    Another soap fault, right?  Yeah, but this time it doesn't die, and svcutil.exe starts a new SSL/TLS session (as indicated by a client hello), and using HTTP GET this time, not POST:

    GET /WSTests/MathService.asmx?WSDL HTTP/1.1
    
    User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 2.0.50727.3082)
    
    Host: Server.com
    
    Connection: Keep-Alive
    
    
    
    HTTP/1.1 200 OK
    
    X-Backside-Transport: OK OK
    
    Connection: Keep-Alive
    
    Transfer-Encoding: chunked
    
    User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 2.0.50727.3082)
    
    Host: 127.0.0.1:63505
    
    Via: 1.1 system-wsgw-management-loopback
    
    X-Client-IP: 127.0.0.1,1.2.3.4

    Cache-Control: no-transform X-Archived-Client-IP: 1.2.3.4,127.0.0.1 Content-Type: text/xml Date: Mon, 04 May 2009 19:47:02 GMT c63 <?xml version="1.0" encoding="UTF-8"?> <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap11="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsp200409="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsp200607="http://www.w3.org/2006/07/ws-policy" xmlns:ns0="http://Server2.com/WSTests/" targetNamespace="http://Server2.com/WSTests/"> <wsdl:types xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:schema> <xsd:import schemaLocation="MathService.asmx.xsd1.xsd" namespace="http://server2.com/WSTests/"/></xsd:schema></wsdl:types> <wsdl:message name="AddMathServiceSoapHeader"> <wsdl:part name="MathServiceSoapHeader" element="xsns:MathServiceSoapHeader" xmlns:xsns="http://server2.com/WSTests/"/></wsdl:message> <wsdl:message name="AddSoapIn"> <wsdl:part name="parameters" element="xsns:Add" xmlns:xsns="http://server2.com/WSTests/"/></wsdl:message> <wsdl:message name="AddSoapOut"> <wsdl:part name="parameters" element="xsns:AddResponse" xmlns:xsns="http://server2.com/WSTests/"/></wsdl:message> <wsdl:portType name="MathServiceSoap"> <wsdl:operation name="Add"> <wsdl:input name="AddRequest" message="ns0:AddSoapIn"/> <wsdl:output name="AddResponse" message="ns0:AddSoapOut"/></wsdl:operation></wsdl:portType> <wsdl:binding name="MathServiceSoap" type="ns0:MathServiceSoap"> <soap11:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/> <wsdl:operation name="Add"> <soap11:operation soapAction="http://server2.com/WSTests/Add" style="document"/> <wsdl:input name="AddRequest"> <soap11:body use="literal"/> <soap11:header message="ns0:AddMathServiceSoapHeader" part="MathServiceSoapHeader" use="literal"/></wsdl:input> <wsdl:output name="AddResponse"> <soap11:body use="literal"/> <soap11:header message="ns0:AddMathServiceSoapHeader" part="MathServiceSoapHeader" use="literal"/></wsdl:output></wsdl:operation></wsdl:binding> <wsdl:binding name="MathServiceSoap12" type="ns0:MathServiceSoap"> <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/> <wsdl:operation name="Add"> <soap12:operation soapAction="http://server2/WSTests/Add" soapActionRequired="false" style="document"/> <wsdl:input name="AddRequest"> <soap12:body use="literal"/> <soap12:header message="ns0:AddMathServiceSoapHeader" part="MathServiceSoapHeader" use="literal"/></wsdl:input> <wsdl:output name="AddResponse"> <soap12:body use="literal"/> <soap12:header message="ns0:AddMathServiceSoapHeader" part="MathServiceSoapHeader" use="literal"/></wsdl:output></wsdl:operation></wsdl:binding> <wsdl:service name="MathService"> <wsdl:port name="MathServiceSoap" binding="ns0:MathServiceSoap"> <soap11:address location="http://server.com:80/WSTests/MathService.asmx"/></wsdl:port> <wsdl:port name="MathServiceSoap12" binding="ns0:MathServiceSoap12"> <soap12:address location="http://Server.com:80/WSTests/MathService.asmx"/></wsdl:port></wsdl:service></wsdl:definitions> 0 GET /WSTests/MathService.asmx.xsd1.xsd HTTP/1.1 User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 2.0.50727.3082) Host: Server.com

    Connection: Keep-Alive HTTP/1.1 200 OK X-Backside-Transport: OK OK Connection: Keep-Alive Transfer-Encoding: chunked User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 2.0.50727.3082) Host: 127.0.0.1:63505 Via: 1.1 system-wsgw-management-loopback X-Client-IP: 127.0.0.1,1.2.3.4

    Cache-Control: no-transform X-Archived-Client-IP: 1.2.3.4,127.0.0.1 Content-Type: text/xml Date: Mon, 04 May 2009 19:47:02 GMT 5b5 <?xml version="1.0" encoding="UTF-8"?> <s:schema xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://Server2.com/WSTests/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" elementFormDefault="qualified" targetNamespace="http://Server2.com/WSTests/"> <s:element name="Add"> <s:complexType> <s:sequence> <s:element minOccurs="1" maxOccurs="1" name="num1" type="s:int"/> <s:element minOccurs="1" maxOccurs="1" name="num2" type="s:int"/> </s:sequence> </s:complexType> </s:element> <s:element name="AddResponse"> <s:complexType> <s:sequence> <s:element minOccurs="1" maxOccurs="1" name="AddResult" type="s:int"/> </s:sequence> </s:complexType> </s:element> <s:element name="MathServiceSoapHeader" type="tns:MathServiceSoapHeader"/> <s:complexType name="MathServiceSoapHeader"> <s:sequence> <s:element minOccurs="0" maxOccurs="1" name="headerValue" type="s:string"/> </s:sequence> <s:anyAttribute/> </s:complexType> </s:schema> 0
    You can see in the above that it is now not getting a soap fault but returning the WSDL and Schema like it should, because it is using HTTP GET which the server expects.

    So, my question is, how can I tell svcutil.exe to always use HTTP post and not GET?  Why would it even use POST to get a WSDL?

    And why is svcutil.exe bahaving differently for each scenario?
    Monday, May 04, 2009 7:59 PM
  • So I guess that there is no way to configure svcutil to only use HTTP Get rather than HTTP Post.
    Tuesday, May 05, 2009 5:51 PM