Click here to Skip to main content
15,889,768 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am developing a web service that needs to sit on a secure server. I've done this in the web config:
HTML
<behaviors>
    <serviceBehaviors>
        <behavior name="StdBehavior">
            <serviceMetadata httpGetEnabled="true"/>
            <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
    </serviceBehaviors>
</behaviors>

<bindings>
    <basicHttpBinding >
        <binding name="secureBinding">
            <security mode="Transport">
                <transport clientCredentialType="Certificate" />
            </security>
        </binding>
    </basicHttpBinding>
</bindings>

<services>
    <service behaviorConfiguration="StdBehavior" name="A.DevelopmentSvc">
        <host>
            <baseAddresses>
                <add baseAddress="https://blah/blah/CrisSvc"/>
            </baseAddresses>
        </host>
        <endpoint address="/" 
                  binding="basicHttpBinding" 
                  bindingConfiguration="secureBinding" 
                  name="devEndpoint" contract="CrisCodeWcf.ICrisSvc" 
                  />
        <endpoint address="mex" 
                  binding="mexHttpsBinding" 
                  name="mexEndpoint" 
                  contract="IMetadataExchange" 
                  />
    </service>
</services>

...but I get this error when I try to browse to the service in IE:

Could not find a base address that matches scheme http for the endpoint with binding WSHttpBinding. Registered base address schemes are [https].
Posted

Hi John,

I usually run svcutil directly, using a batch file. This has a few benefits, chief among them is that you don't need to talk to a running service.

svcutil is capable of generating the required code based on your service definition from the implementation assembly.

Here is the contents of a batch file I use for this purpose:

SETLOCAL

rem set up path so svcutil can be found
call c:\usr\bin\initvc.cmd


SET ROOTDIR=C:\Src\AjaWorks\AjaWorks.Oracle.Tools

rem this is where the service implmentation assembly is located
SET WCFSERVICEDIR=%ROOTDIR%\Goodtech.Databox.DX.DataService\bin\Debug

SET WCFSERVICECLIENTDIR=%ROOTDIR%\Generated

rem this assembly contains types shared between the client and server
SET COMMONTYPESDLL=%ROOTDIR%\Generated\bin\Debug\Goodtech.Databox.DX.dll


cd %WCFSERVICECLIENTDIR%\wsdl

rem let svcutil generate wsdl
svcutil %ROOTDIR%\Goodtech.Databox.DX.DataService\bin\Debug\Goodtech.Databox.DX.DataService.dll

CD %WCFSERVICECLIENTDIR%\Client

rem let svcutil generate code ( service reference )
svcutil %WCFSERVICECLIENTDIR%\wsdl\*.wsdl %WCFSERVICECLIENTDIR%\wsdl\*.xsd /namespace:*,Goodtech.Databox.DX.Client /targetClientVersion:Version35 /language:C# /ct:System.Collections.Generic.List`1 /out:DataServiceReference.cs /config:GeneratedApp.config /reference:%COMMONTYPESDLL%

ENDLOCAL


A typical solution will usually have at least:

  • An assembly for types shared between client and server
  • An assembly for the service implementation
  • A windows forms application that hosts the service implementation - for development purposes
  • A windows service that hosts the service implementation - for deployment
  • A client API assembly that wraps the code generated by svcutil, adds logging, connection handling, etc.
  • The client application


Everything that determines how the client and server talks to each other goes into the application configuration files.

Best regards
Espen Harlinn
 
Share this answer
 
It appears that you can't use the basicHttpBinding under the bindings for https, check this link where they had the exact same problem and used webhttpbinding.

WCF Bindings needed for HTTPS[^]
 
Share this answer
 
I guess, you cannot use clientCredentialType="Certificate" with basicHttpBinding.

try using clientcredentialtype="None".

Edit: Another point to make:

you have written:
<serviceMetadata httpGetEnabled="true"/>

I guess it needs to be:
XML
<behavior name="StdBehavior">
          <serviceMetadata httpsGetEnabled="true" />
        </behavior>
        <behavior name="">
          <serviceMetadata httpGetEnabled="true" />
        </behavior>
 
Share this answer
 
v4
As others have pointed out the binding will probably need to change; something like wsHttpBinding. I have found this link to msdn helpful:

Common Security Scenarios[^]

Also, to get your wsdl you will probably need to turn on:
HTML
<servicemetadata httpsgetenabled="true"></servicemetadata>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900