Expose WSDL

Working with my java colleagues I came to love SOAPUI for testing services. Now Microsoft seems to have catched up with the WCF Test Client. A blog post of dotNET colleague Rick van den Bosch made me search for it in the Common7 folder.
Adding a service is done by putting the URL to the WSDL in the inputbox. So I had to make sure my services expose the WSDL. See below for some configuration options for exposing the WSDL. In both cases the WSDL is exposed on http://SomeMachine/Some/Services/Calculator?wsdl

<!-- Make use of a named behavior configuration -->
<system.serviceModel>
  <services>
    <!-- Service with specified behavior, 
         the behavior contains the address for the WSDL -->
    <service name                  = "SomeService.CalculateImplementation"
             behaviorConfiguration = "CaculateServiceWSDLBehavior" >
      <endpoint
        address                    = "http://SomeMachine/Some/Services/Calculator"
        binding                    = "basicHttpBinding"
        contract                   = "SomeService.ICalculate"
      />
    </service>
  </services>
  <behaviors>
    <serviceBehaviors>
      <!-- Named behavior containing the WSDL URL (httpGetUrl) -->
      <behavior name               = "CaculateServiceWSDLBehavior">
        <serviceMetadata 
          httpGetEnabled           = "true"
          httpGetUrl               = "http://SomeMachine/Some/Services/Calculator" />
      </behavior>
    </serviceBehaviors>
  </behaviors>
</system.serviceModel>
<!-- Make use of baseAddress -->
<system.serviceModel>
  <services>
    <!-- Service with default behavior -->
    <service name                = "SomeService.CalculateImplementation" >
      <!-- baseAddress used for WSDL url -->
      <host>
        <baseAddresses>
          <add baseAddress       = "http://SomeMachine/Some/Services/Calculator" />
        </baseAddresses>
      </host>
      <!-- Endpoint without address, because that is fully 
           specified in the baseAddress -->
      <endpoint
        address                  = ""
        binding                  = "basicHttpBinding"
        contract                 = "SomeService.ICalculate" />
    </service>
  </services>
  <behaviors>
    <serviceBehaviors>
      <!-- Default behavior for every service 
           use of baseAddress needed for WSDL -->
      <behavior>
        <serviceMetadata 
          httpGetEnabled         = "true" />
      </behavior>
    </serviceBehaviors>
  </behaviors>
</system.serviceModel>

Need some online service to get started with WCF Test Client? Check webservicex.

About erictummers

Working in a DevOps team is the best thing that happened to me. I like challenges and sharing the solutions with others. On my blog I’ll mostly post about my work, but expect an occasional home project, productivity tip and tooling review.
This entry was posted in Development and tagged , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.