svcutil doesn't generate config file

10,448

Endpoints which use the WebHttpBinding (a.k.a., WCF WebHttp endpoints), do not expose metadata like "normal" (i.e., SOAP) endpoints do. WCF will still generate a WSDL for your service (since you specified <serviceMetadata httpGetEnabled="true"/>), but the metadata will only contain certain aspects of the service (such as data contracts, etc). The Web-related features (WebInvoke/WebGet attributes) won't be on the proxy, so even though you get a proxy file, you'll likely won't be able to use it to communicate to the service (unless you didn't use any of those). The problem is that there's no widely accepted format for describing metadata for REST services (WADL is possibly the most used, but it's not nearly as prevalent as WSDL for SOAP, and it's not implemented by WCF).

In short: svcutil doesn't really work for web endpoints.

If you want the long version: http://blogs.msdn.com/b/carlosfigueira/archive/2012/03/26/mixing-add-service-reference-and-wcf-web-http-a-k-a-rest-endpoint-does-not-work.aspx

Share:
10,448
vpp
Author by

vpp

Updated on August 09, 2022

Comments

  • vpp
    vpp over 1 year

    I have wcf service. I tried to generate proxy code and configuration file for client program by svcutil:

    svcutil http://localhost/WcfService2/Files.svc
    

    I got valid file with proxy, but didn't get config file. Why? (VS2010 SP1, .NET 4.0, IIS 7.0)

    My service contract:

    [ServiceContract]
    public interface IFiles
    {
        [OperationContract]
        Guid UploadFile(Stream stream);
    }
    

    My web config:

    <?xml version="1.0"?>
    <configuration>
    
      <system.serviceModel>
        <bindings>
          <webHttpBinding>
            <binding name="WebHttpBinding" maxBufferSize="65536" maxBufferPoolSize="524288"
              maxReceivedMessageSize="1073741824" transferMode="Streamed" />
          </webHttpBinding>
        </bindings>
        <services>
          <service behaviorConfiguration="MyServiceBehavior" name="WcfService2.Files">
            <endpoint behaviorConfiguration="WebHttpBehavior" binding="webHttpBinding"
              bindingConfiguration="WebHttpBinding" name="Files" contract="WcfService2.IFiles" />
          </service>
        </services>
        <behaviors>
          <endpointBehaviors>
            <behavior name="WebHttpBehavior">
              <webHttp defaultBodyStyle="Wrapped" defaultOutgoingResponseFormat="Json"
                automaticFormatSelectionEnabled="false" />
            </behavior>
          </endpointBehaviors>
          <serviceBehaviors>
            <behavior name="MyServiceBehavior">
              <serviceMetadata httpGetEnabled="true" />
              <serviceDebug/>
            </behavior>
          </serviceBehaviors>
        </behaviors>
      </system.serviceModel>
      <system.web>
        <httpRuntime maxRequestLength="100000" />
      </system.web>
    
    </configuration>
    
  • vpp
    vpp almost 13 years
    It's not true. I tried to make simple project at home (under VS2008, .NET 3.5). Service endpoint was configurated with webHttpBinding and webHttp behavior element. Command svcutil.exe localhost:3065/Service1.svc?wsdl got both the proxy and the config file.
  • carlosfigueira
    carlosfigueira almost 13 years
    Check the binding that is used in the config file - it will not be webHttpBinding. You're probably hitting some default endpoint on the service.
  • vpp
    vpp almost 13 years
    The service has only one endpoint. svcutil makes a base for the client witch has access to endpoint through SOAP (messageVersion="Soap12" of textMessageEncoding of customBinding). And it is described in config file. First sample didn't have it at all.
  • carlosfigueira
    carlosfigueira almost 13 years
    What svcutil created is not a binding equivalent to a webHttpBinding (webHttpBinding has no SOAP version, equivalent to messageVersion.None). svcutil is creating the client config for another endpoint which exists on the service, not the one endpoint with webHttpBinding/webHttp behavior. WebHttpBinding endpoints are not exposed in the WSDL / metadata, which is what svcutil uses.
  • vpp
    vpp almost 13 years
    It's clear. Not every WCF-service has metadata to make client "turnkey". Thank you, carlosfigueira.
  • Guillermo Varini
    Guillermo Varini about 12 years
    @carlosfigueira if svcutil cant create .config, how do i have to chance the app.config so it can find the endpoint of the wcf?? error i get: Could not find default endpoint element that references contract.....regards
  • Yuval A.
    Yuval A. about 12 years
    Had the same problem. this helped to solve it: msdn.microsoft.com/en-us/library/ms734663.aspx