Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to test WCF service with TransportWithMessageCredential in VS2010 built-in web server

I'm developing a WCF Service with a custom UserNamePasswordValidatorwith a basicHttpBinding. This configuration, however, works only on HTTPS binding. Since Visual Studio 2010's built in web server does not support https, how can I test my custom validator? I keep getting Could not find a base address that matches scheme https for the endpoint with binding BasicHttpBinding. Registered base address schemes are [http]. error and, if I set the clientCredentialType to none, the error is gone, but the validator does not get called.
Below is my configuration.

<?xml version="1.0"?>
<configuration>
  <system.serviceModel>
    <extensions>
      <behaviorExtensions>
        <add name="ServiceErrorHandler" type="company.application.appserver.implementation.ServiceErrorHandlerBehaviorExtensionElement, AppSoftAppServer, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
      </behaviorExtensions>
    </extensions>
    <bindings>
      <basicHttpBinding>
        <binding name="SimpleBinding">
          <security mode="TransportWithMessageCredential">
            <message clientCredentialType="UserName"/>
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <services>
      <service behaviorConfiguration="DefaultBehavior" name="company.application.appserver.implementation.AppSoftUpdate">
        <endpoint address="udt" binding="basicHttpBinding" bindingConfiguration="SimpleBinding"
          name="AppSoftUpdate" bindingNamespace="http://company.application/update/2011/04"
          contract="company.application.appserver.interfaces.IAppSoftUpdate" />
        <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration=""
          name="AppSoftUpdateMex" bindingNamespace="http://company.application/update/2011/04"
          contract="IMetadataExchange" />
      </service>
      <service behaviorConfiguration="DefaultBehavior" name="company.application.appserver.implementation.AppSoftTransaction">
        <endpoint address="udt" binding="basicHttpBinding" bindingConfiguration="SimpleBinding"
          name="AppSoftTransacao" bindingNamespace="http://company.application/transaction/2011/04"
          contract="company.application.appserver.interfaces.IAppSoftTransacao" />
        <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration=""
          name="AppSoftTransacaoMex" bindingNamespace="http://company.application/transaction/2011/04"
          contract="IMetadataExchange" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="DefaultBehavior">
          <serviceMetadata httpGetEnabled="true" httpGetBinding="webHttpBinding"
            httpGetBindingConfiguration="" />
          <serviceDebug includeExceptionDetailInFaults="true" />
          <ServiceErrorHandler />
          <serviceCredentials>
            <userNameAuthentication userNamePasswordValidationMode="Custom"
              customUserNamePasswordValidatorType=" company.application.appserver.implementation.AppSoftValidacaoLogin, AppSoftAppServer" />
          </serviceCredentials>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
</configuration>
like image 560
Pascal Avatar asked May 22 '11 18:05

Pascal


1 Answers

Use IIS for this testing.

Open your project properties, go to the Web tab, hit Use local IIS radio button. This manual is valid for VS2010 too: Using Visual Studio 2008 with IIS 7

If IIS is not installed yet, install it first: How to install IIS.

You need to have Windows edition higher than Windows Home.

You will also need to create a self-signed certificate for your web site. This is easy to do in IIS 7: Self-Signed Certificates on IIS 7 – the Easy Way and the Most Effective Way

like image 110
Alex Aza Avatar answered Oct 03 '22 07:10

Alex Aza