web.config transformer does nothing - asp.net

I'm trying to use the web.config transformer, but it does nothing.
Here is my last part of web.config:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IUserInterfaceService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://[WhiteOPS User Interface]:[Port]/UIService/UserInterfaceService/"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IUserInterfaceService"
contract="UserInterface.IUserInterfaceService" name="BasicHttpBinding_IUserInterfaceService" />
</client>
and here is my web.debug.config:
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<endpoint name="BasicHttpBinding_IUserInterfaceService" address="http://localhost:80/UIService/UserInterfaceService/"
xdt:Transform="SetAttributes" xdt:Locator="Match(name)" />
when i run (with or without debuging mode) in the debug configuration, i'm getting an error that this line cannot compiled:
<endpoint address="http://[WhiteOPS User Interface]:[Port]/UIService/UserInterfaceService/"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IUserInterfaceService"
contract="UserInterface.IUserInterfaceService" name="BasicHttpBinding_IUserInterfaceService" />
so why the transformation not happening?
Thanks,

You need to build it up in the same structure as your other web.config.
So you need to wrap it with the same <client> tag, so that the transformer can find it in the same location.
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<client>
<endpoint name="BasicHttpBinding_IUserInterfaceService" address="http://localhost:80/UIService/UserInterfaceService/" xdt:Transform="SetAttributes" xdt:Locator="Match(name)" />
</client>
Hope this helps!

Related

Check WCF service is working or not by output typing URL

I have created a WCF service in ASP.net. I want to check the service is working or not before moving forward.
So can sombody suggests what is the exact URL to type and see the output.
Find my web.config file.
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IService1" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text"
textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" establishSecurityContext="true" />
</security>
</binding>
<binding name="WSHttpBinding_IService11" />
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8732/Design_Time_Addresses/WcfServiceLibrary1/Service1/"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IService1"
contract="Myservice.IService1" name="WSHttpBinding_IService1">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="http://localhost:8732/Design_Time_Addresses/WcfServiceLibrary1/Service1/"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IService11"
contract="ServiceReference1.IService1" name="WSHttpBinding_IService11">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
</system.serviceModel>
you can use wcftestclient to test service
you can set the wcf project as startup project and debug the solution, it will start in wcftestclient and automatically add your service.
or open directly from "C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\WcfTestClient.exe" - VS2010
from here you can invoke the serviceby passing parameters(if any) and test.
here is another link
If you mean check at the client side,then you can catch the Exception like below and do what you want to do
CommunicationObjectFaultedException //Communication is wrong
EndpointNotFoundException //EndPoint is not found or working
FaultException //FaultException thrown by the server

The remote server returned an unexpected response: (413) Request Entity Too Large (service config vs client config)

There are a number of post already out there but I cannot get this to work. The posts suggest to define the tags endpoints and binding both client side and server side. All I have is the applications web.config file. How do I make the distinction between client side and server side. In my web.config, i defined a services tag, but it seems as if it is not used as the face binding configurations defined in there is never called out when debugging. My web.config looks like this:
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="****" type="****, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=*********" >
<section name="********" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=*********" requirePermission="false" />
</sectionGroup>
</configSections>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="binding1_IService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true" messageEncoding="Text">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
<binding name="binding2_IService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true" messageEncoding="Text">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http:aaa.com/bbb.xamlx" binding="basicHttpBinding" bindingConfiguration="binding1_IService" contract="App.IAppService" />
<endpoint address="http:aaa.com/bbb.xamlx" binding="basicHttpBinding" bindingConfiguration="binding2_IService" contract="App2.IApp2Service" />
</client>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<!--Not sure this is where to put this and if it is correct -->
<services>
<service name="namespace.classname">
<endpoint address="http:aaa.com/bbb.xamlx" binding="basicHttpBinding" contract="App.IAppService" bindingConfiguration="binding1.IService" />
<endpoint address="http:aaa.com/bbb.xamlx" binding="basicHttpBinding" contract="App.IAppService2" bindingConfiguration="binding2.IService" />
</service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.web>
<customErrors mode="Off" />
<compilation debug="true" targetFramework="4.0" />
<authentication mode="Windows" />
<authorization>
<deny users="?"/>
</authorization>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
<connectionStrings>
<add name="name" connectionString="string" providerName="System.Data.EntityClient" />
</connectionStrings>
</configuration>
I keep getting the error above when uploading non-text files. Any help please...
I got the same issue with xamlx (Windows Workflow Foundation Web Services), and I tried a bunch of WCF solutions with no success, but I found the following solution on the asp.net forum; which worked perfectly even on IIS Express.
Reference: Problem with XAMLX service in .Net 4.0

How to increase the maxlenght in web.Config and App.Config to upload the image?

In my program I am trying to save image to database. I am getting an exception
protocol exception was unhandled" The remote server returned an unexpected response (400) Bad Request
I looked up on google and I found to change maximum message length in app.config. I tried that but even that did not work. Here is my app.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService1" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false"
hostNameComparisonMode="StrongWildcard"
maxBufferSize="524288" maxBufferPoolSize="524288" maxReceivedMessageSize="524288"
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://localhost:55750/Service1.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService1" contract="PeerService.IService1"
name="BasicHttpBinding_IService1" />
</client>
</system.serviceModel>
</configuration>
Can you please tell me how to fix it?I am really stuck in this problem....
Try upping all your values:
<!-- Used by basic WCF Services -->
<binding maxBufferPoolSize="20000000" maxBufferSize="20000000" maxReceivedMessageSize="20000000">
<readerQuotas maxDepth="32" maxStringContentLength="20000000" maxArrayLength="20000000" maxBytesPerRead="20000000" maxNameTableCharCount="20000000"/>
</binding>

WCF throws Exception When the passed list size is large

I use WCF in my application. from Application I Pass a list to process at backend through WCF. If the no Of rows in the list is large then The service throws the exception "The remote server returned an unexpected response: (400) Bad Request."
below is my UI web config
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService1" closeTimeout="10:20:00"
openTimeout="10:20:00" receiveTimeout="10:20:00" sendTimeout="10:20:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None">
<transport clientCredentialType="Windows" proxyCredentialType="Windows"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
<binding name="BasicHttpBinding_IErrorService" closeTimeout="10:20:00"
openTimeout="10:20:00" receiveTimeout="10:20:00" sendTimeout="10:20:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
<binding name="BasicHttpBinding_IService11" closeTimeout="10:20:00"
openTimeout="10:20:00" receiveTimeout="10:20:00" sendTimeout="10:20:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None">
<transport clientCredentialType="Windows" proxyCredentialType="Windows"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
<binding name="BasicHttpBinding_ISecurityUserService" closeTimeout="10:20:00"
openTimeout="10:20:00" receiveTimeout="10:20:00" sendTimeout="10:20:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None">
<transport clientCredentialType="Windows" proxyCredentialType="Windows"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:6789/Service1.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService1" contract="ServiceReference1.IService1"
name="BasicHttpBinding_IService1" />
<endpoint address="http://localhost:6789/ErrorService.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IErrorService" contract="ErrorServiceReference.IErrorService"
name="BasicHttpBinding_IErrorService" />
<endpoint address="http://localhost:6789/SecurityUserService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ISecurityUserService"
contract="SecurityUserServiceReference.ISecurityUserService"
name="BasicHttpBinding_ISecurityUserService" />
<endpoint address="http://localhost:6789/Service1.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService11" contract="ServiceReference.IService1"
name="BasicHttpBinding_IService11" />
</client>
</system.serviceModel>
also added the below tag To WCF Web config as well as UI Web config
<system.web>
<httpRuntime maxRequestLength="512000" />
</system.web>
MY service Config is As below
<httpRuntime maxRequestLength="512000" />
ServiceModel :
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<modules runAllManagedModulesForAllRequests="true"/>
I modified the service Web config . still i am getting the Same issue. Please help me on this
<services>
<service name="BasicHttpBinding_IService1" behaviorConfiguration="Behavior">
<endpoint address=""
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService1"
contract="ServiceReference1.IService1"/>
</service>
<service name="BasicHttpBinding_IErrorService" behaviorConfiguration="Behavior">
<endpoint address=""
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IErrorService"
contract="ErrorServiceReference.IErrorService"/>
</service>
<service name="BasicHttpBinding_ISecurityUserService" behaviorConfiguration="Behavior">
<endpoint address=""
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_ISecurityUserService"
contract="SecurityUserServiceReference.ISecurityUserService"/>
</service>
</services>
and bindings
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService1" closeTimeout="10:20:00"
openTimeout="10:20:00" receiveTimeout="10:20:00" sendTimeout="10:20:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None">
<transport clientCredentialType="Windows" proxyCredentialType="Windows"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
<binding name="BasicHttpBinding_IErrorService" closeTimeout="10:20:00"
openTimeout="10:20:00" receiveTimeout="10:20:00" sendTimeout="10:20:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
<binding name="BasicHttpBinding_ISecurityUserService" closeTimeout="10:20:00"
openTimeout="10:20:00" receiveTimeout="10:20:00" sendTimeout="10:20:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None">
<transport clientCredentialType="Windows" proxyCredentialType="Windows"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
You don't appear to have any endpoints or bindings defined in your service config, which means you're getting default endpoints and bindings. Since your service is using the default binding and its default values, it can't receive the large message.
You can override the default binding settings by omitting the name attribute in the binding element. However, in your case you have different settings in your three defined bindings (in the security portion, at least). So you'll need to both define the bindings and assign them to endpoints.
Try something like this:
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService1" .....>
</basicHttpBinding>
</bindings>
I've omitted most of the binding declaration - you can simply copy them from your client config.
Then in the service you assign a specific binding configuration with the bindingConfig attribute on the endpoint element, like this:
<services>
<service .... >
<endpoint address="http://localhost:6789/Service1.svc"
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService1"
contract="ServiceReference1.IService1"
name="BasicHttpBinding_IService1" />
</service>
</services>
Again, I've omitted most of the configuration code for simplicity.
The key point here is that the service needs to have a binding that is configured to accept larger messages than the defaults. Increasing the maxRequestLength for the runtime doesn't affect the WCF services directly (unless you have request larger than the HTTP runtime value, of course).
You can read more about default endpoints and bindings here - A Developer's Introduction to Windows Communication Foundation 4

Use WCF Client to consume Non-WCF Service and pass Client Certificate

I have an ASP.NET application that calls a Java Web Service using a WCF Client. The communication works until a certificate is required. I updated the config, but I'm receiving errors on call. Does anyone have good example of the configuration? The certificate is stored in Certificate Store.
Config that works when Client Certificate is not needed:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="DocManagementSOAP" 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="Mtom" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://acme.com/services/docmanagement_V3"
binding="basicHttpBinding"
bindingConfiguration="DocManagementSOAP"
contract="FileNetDmsServiceReference.docManagement"
name="DocManagementSOAP" />
</client>
</system.serviceModel>
Config that is failing that I'm trying to setup to pass Client Cert:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="DocManagementSOAP"
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="Mtom"
textEncoding="utf-8"
transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="Transport">
<transport clientCredentialType="Certificate" proxyCredentialType="None" realm=""/>
<message clientCredentialType="Certificate" algorithmSuite="Default"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://acme.com/services/docmanagement_V3"
binding="basicHttpBinding"
bindingConfiguration="DocManagementSOAP"
behaviorConfiguration="CertificateBehavior"
contract="ServiceReference.docManagement"
name="DocManagementSOAP">
<identity>
<dns value="cert.acme.com" />
</identity>
</endpoint>
</client>
<behaviors>
<endpointBehaviors>
<behavior name="CertificateBehavior">
<clientCredentials>
<clientCertificate x509FindType="FindBySubjectName" findValue="cert.acme.com" storeLocation="LocalMachine"/>
<serviceCertificate>
<authentication certificateValidationMode="PeerOrChainTrust"
revocationMode="NoCheck"
trustedStoreLocation="LocalMachine" />
</serviceCertificate>
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
After working with Microsoft Tech support, this is configuration finally worked:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="DocManagementSOAP"
messageEncoding="Mtom"
textEncoding="utf-8">
<security mode="Transport">
<transport clientCredentialType="Certificate" proxyCredentialType="None" realm="" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://acme.com/services/docmanagement_V3"
binding="basicHttpBinding"
behaviorConfiguration="cert"
bindingConfiguration="DocManagementSOAP"
contract="docManagement"
name="DocManagementSOAP" />
</client>
<behaviors>
<endpointBehaviors>
<behavior name="cert">
<clientCredentials>
<clientCertificate findValue="cert.acme.com"
storeLocation="LocalMachine"
storeName="My"
x509FindType="FindBySubjectName"/>
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
Note: If your service doesn't support MTOM, remove or change the messageEncoding attribute.

Resources