none
WCF Config using SvcUtil.exe RRS feed

  • Question

  • I am using SvcUtil.exe tool to create a WCF service (.Net 4.0) from the existing WSDL I have. When I see the output.config generated, I don't see "<services>" tag, instead I see Client tag in config. 

    Here is my original WSDL:

    <?xml version="1.0" encoding="UTF-8"?>
    <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" name="AcctSetupParticipant" targetNamespace="http://interfaces/AcctSetup/AcctSetupParticipant/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://interfaces/AcctSetup/AcctSetupParticipant/" xmlns:wsdl_1="http://interfaces/AcctSetup/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <wsdl:import location="AcctSetup.wsdl" namespace="http://interfaces/AcctSetup/"/>
      <wsdl:binding name="AcctSetupBinding" type="wsdl_1:AcctSetup">
        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
        <wsdl:operation name="Setup">
          <soap:operation soapAction="http://interfaces/AcctSetup/AcctSetupParticipant/Setup/"/>
          <wsdl:input>
            <soap:body parts="request" use="literal"/>
          </wsdl:input>
          <wsdl:output>
            <soap:body parts="response" use="literal"/>
          </wsdl:output>
        </wsdl:operation>
      </wsdl:binding>
      <wsdl:service name="AcctSetup">
        <wsdl:port binding="tns:AcctSetupBinding" name="AcctSetupPort">
          <soap:address location="http://interfaces/AcctSetup/AcctSetupParticipant/AcctSetup/AcctSetupPort"/>
        </wsdl:port>
      </wsdl:service>
    </wsdl:definitions>


    Here is my Command I use in SvcUtil.exe to generate Service Interface and Config from existing WSDL

    svcutil /s /language:C# /out:IAcctSetup.cs "AcctSetupParticipant.wsdl" "AcctSetup.wsdl" "parts.xsd"

    Here is generated output.config

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
        <system.serviceModel>
            <bindings>
                <basicHttpBinding>
                    <binding name="AcctSetupBinding" closeTimeout="00:01:00" openTimeout="00:01:00"
                        receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
                        bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                        maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                        messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                        useDefaultWebProxy="true">
                        <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                        <security mode="None">
                            <transport clientCredentialType="None" proxyCredentialType="None"
                                realm="" />
                            <message clientCredentialType="UserName" algorithmSuite="Default" />
                        </security>
                    </binding>
                </basicHttpBinding>
            </bindings>
            <client>
                <endpoint address="http://interfaces/AcctSetup/AcctSetupParticipant/AcctSetup/AcctSetupPort"
                    binding="basicHttpBinding" bindingConfiguration="AcctSetupBinding"
                    contract="AcctSetup" name="AcctSetupPort" />
            </client>
        </system.serviceModel>
    </configuration>

    as you see in config, Client tag presents but no Service tag. Also when I generate the WCF Service by implementing the Interface created from above Svc command, I don't see the operation in WCF Service WSDL.

    I have been researching now for long. Any help will be appreciated.


    Chintan

    Friday, April 19, 2013 5:02 PM

Answers

All replies

  • The svcutil.exe code generation feature does generate the services configuration element because it is not generating code and configuration for the service.  It is generating code and configuration for the client.  The services element is only present service-side, as such it is not generated.

    Please review the following article on the svcutil.exe, which has a detailed explanation of the features of this utility:  http://msdn.microsoft.com/en-us/library/aa347733.aspx

    Note that you can use some of the code/configuration generated towards a service if you are starting with a WSDL file, but the svcutil.exe does not set that up entirely for you.

    • Edited by BotHead Friday, April 19, 2013 6:57 PM
    Friday, April 19, 2013 6:52 PM
  • Hello,

    I want to generate the Service only (meaning the service interface and required classes) and not the Client Proxy, I am sorry if I have misunderstood what you wrote.

    To my understanding, SvcUtil.exe can generate the Service Interface, Data Contract Classes and Configuration (which you can use in your web.config) - After implementing the generated interface, I will have my WCF service up and running...Am I making sense here?


    Chintan


    Friday, April 19, 2013 6:56 PM
  • I do not think there is an option to tell the svcutil to skip generating the client proxy.  With that said, the same command you listed above will generate the service contracts and its required classes (i.e. any data contracts defined) along with the services binding configurations, which you will want for the service-side configuration.  You will just have the client proxy in addition, which you can ignore since it won't hurt anything to have it.  You will additionally need to manually create the appropriate implementation of that service interface and remaining configuraiton elements (i.e. the services element you mentioned).

    So... if you open up the IAcctSetup.cs file from you command everything will be in there.  If the client proxy is really bothering you you can delete it, but since this is generated code I would suggest you leave it in place since the next time you re-generate it it will just get added again.

    Friday, April 19, 2013 7:05 PM
  • Yes, got that point. I was under impression that it will create a Services Configuration by itself. 

    I knew it will create a Client Proxy class also and I am not bothered about it.

    I tried creating the Services element in the Web.Config still the operation does not show up in the WSDL.

    Here is my Web.Config part of it..

    <system.serviceModel>
        <behaviors>
          <serviceBehaviors>
            <behavior name="metadataServiceExtension">
              <serviceMetadata httpGetEnabled="true" />
              <serviceDebug includeExceptionDetailInFaults="false" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
        <bindings>
          <basicHttpBinding>
            <binding name="AcctSetupBinding" closeTimeout="00:01:00" openTimeout="00:01:00"
                receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
                bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                useDefaultWebProxy="true">
              <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                  maxBytesPerRead="4096" maxNameTableCharCount="16384" />
              <security mode="None">
                <transport clientCredentialType="None" proxyCredentialType="None"
                    realm="" />
                <message clientCredentialType="UserName" algorithmSuite="Default" />
              </security>
            </binding>
          </basicHttpBinding>
        </bindings>
        <!--<client>
          <endpoint address="http://interfaces/AcctSetup/AcctSetupParticipant/AcctSetup/AcctSetupPort"
              binding="basicHttpBinding" bindingConfiguration="AcctSetupBinding"  
                    behaviorConfiguration="metadataServiceExtension" 
              contract="AcctSetup" name="AcctSetupPort" />
        </client>-->
        <services>
          <service behaviorConfiguration="metadataServiceExtension" name="SvcUtilGeneratedService.AcctSetupService">
            <endpoint address=""
                behaviorConfiguration="" binding="basicHttpBinding" bindingConfiguration="AcctSetupBinding" 
                contract="AcctSetup" />
          </service>
        </services>
      </system.serviceModel>


    And here is my WCF WSDL where the operation does not show up...

      <?xml version="1.0" encoding="utf-8" ?> 
    - <wsdl:definitions name="AcctSetupService" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:tns="http://tempuri.org/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:i0="http://interfaces/AcctSetup/" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata">
      <wsdl:import namespace="http://interfaces/AcctSetup/" location="http://localhost:1834/AcctSetup.svc?wsdl=wsdl0" /> 
      <wsdl:types /> 
    - <wsdl:binding name="BasicHttpBinding_AcctSetup" type="i0:AcctSetup">
      <soap:binding transport="http://schemas.xmlsoap.org/soap/http" /> 
      </wsdl:binding>
    - <wsdl:service name="AcctSetupService">
    - <wsdl:port name="BasicHttpBinding_AcctSetup" binding="tns:BasicHttpBinding_AcctSetup">
      <soap:address location="http://localhost:1834/AcctSetup.svc" /> 
      </wsdl:port>
      </wsdl:service>
      </wsdl:definitions>


    Chintan


    Friday, April 19, 2013 7:24 PM
  • The WSDL file you have posted has targetNamespace=http://tempuri.org/.  If you look at the second line of that WSDL file you can see a WSDL import with the location.  Put that location into your browser and you should see the information you are looking for.

    Here is some information about the WSDL standard for imports:
    http://www.w3.org/TR/wsdl20-primer/#import-component

    Friday, April 19, 2013 8:54 PM
  • The issue was caused by the way SvcUtil generated the Service Contract's ReplyAction...

    When I fixed this, the operation started to show up on WSDL.

    I got it from this article http://msdn.microsoft.com/en-us/library/ms735109(v=vs.100).aspx (3rd point)

    If the WSDL does not specify a reply action for all of the operations, the generated operation contracts may have the ReplyAction property set to the wildcard character (*). Remove this property setting. Otherwise, when you implement the service contract metadata, the metadata cannot be exported for those operations.


    Chintan

    Friday, April 19, 2013 9:50 PM
  • Thanks for the follow up!  If you feel that your last post has answered your remaining questions feel free to mark that as the answer or ask any other question you have on this topic.
    • Edited by BotHead Friday, April 19, 2013 10:23 PM
    Friday, April 19, 2013 10:22 PM