Calling a WCF service from another WCF service

Posted by ultraman69 on Stack Overflow See other posts from Stack Overflow or by ultraman69
Published on 2010-03-25T15:10:41Z Indexed on 2010/03/25 15:13 UTC
Read the original article Hit count: 1477

Filed under:

Hi !

I have a WCF service hosted on a windows service on my Server1. It also has IIS on this machine. I call the service from a web app and it works fine. But within this service, I have to call another WCF sevice (also hosted on a windows service) located on Server2. The security credentials are set to "Message" and "Username". I have an error like "SOAP protcol negociation failed". It's a problem with my server certificate public key that doesn't seem to be recognise. However, if I call the service on the Server2 from Server1 in a console app, it works fine.

I followed this tutorial to set up my certificates :

Here's the config file from my service on Server1 that tries to call the second one :

    <endpoint address=""
              contract="Microsoft.ServiceModel.Samples.ITraitement" />

    <endpoint address="mex"
              contract="IMetadataExchange" />


  <endpoint address="http://Server2:8000/servicemodelsamples/service"
    behaviorConfiguration="myClientBehavior" binding="wsHttpBinding"
    bindingConfiguration="MybindingCon" contract="Microsoft.ServiceModel.Samples.ICalculator"
      <dns value="ODWCertificatServeur" />

    <binding name="MybindingCon">
      <security mode="Message">
        <message clientCredentialType="UserName" />

    <behavior name="ServiceTraitementBehavior">
      <serviceMetadata httpGetEnabled="True"/>
      <serviceDebug includeExceptionDetailInFaults="True" />
    <behavior name="myClientBehavior">
        <clientCertificate findValue="MachineServiceTraitement" x509FindType="FindBySubjectName" storeLocation="LocalMachine" storeName="My" />
          <authentication certificateValidationMode="ChainTrust" revocationMode="NoCheck"/>

And here's the config file from the web app that calls the service on Server1 :

    <binding name="WSHttpBinding_ITraitement" 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"
      <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" />
  <endpoint address="http://localhost:8020/ServiceTraitementPC"
      binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_ITraitement"
      contract="ITraitement" name="WSHttpBinding_ITraitement">

Any idea why it works if if I call it in a console app and not from my service ? Maybe it has something to do with the certificateValidationMode="ChainTrust" ?

© Stack Overflow or respective owner

Related posts about wcf

Related posts about wcf-security