0

I have a config entry which is not loaded at run-time under certain conditions which I cannot control. This prevents me from connecting to the WCF service.

How can I force a load the config entry or define the endpoint dynamically at run-time ?

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

  <system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="WSHttpBinding_AReportingService" 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="65536000"
        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="TransportWithMessageCredential">
            <transport clientCredentialType="None" proxyCredentialType="None"
                realm="" />
            <message clientCredentialType="Windows" negotiateServiceCredential="true"
                algorithmSuite="Default" establishSecurityContext="false" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <behaviors>
      <endpointBehaviors>
        <behavior name="MyEndpointBehavior">
          <dataContractSerializer maxItemsInObjectGraph="65536000"/>
        </behavior>
        <behavior name="ImpersonationBehavior">
          <dataContractSerializer maxItemsInObjectGraph="2147483647" />
          <clientCredentials>
            <windows allowedImpersonationLevel="Impersonation"/>
          </clientCredentials>
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <client>
      <endpoint address="https://toto.echonet/AReportingService_strong_auth/AReportingService.svc"
           behaviorConfiguration="ImpersonationBehavior" binding="wsHttpBinding"
          bindingConfiguration="WSHttpBinding_IAReportingService"
          contract="AReportingService.IAReportingService"
          name="WSHttpBinding_IAReportingService" >
        <identity>
          <servicePrincipalName value="mytoto01p@net.intra" />
        </identity>
      </endpoint>
    </client>
  </system.serviceModel>
</configuration>

My issue is that no config file is loaded at all at startup and there is no way for me to modify the application loading my DLL.

EDIT1: I have tried the following, but I think I am missing passing the credentials somehow:

    public static global::AAA.AReportingService.AReportingServiceClient CreateServiceClientInstance()
    {
        WSHttpBinding binding = new WSHttpBinding(SecurityMode.TransportWithMessageCredential);
        EndpointAddress endpoint = new EndpointAddress(new Uri("https://toto.echonet/AReportingService_strong_auth/AReportingService.svc"));

        return new global::AAA.FixLinkReportingService.AReportingServiceClient(
            binding, endpoint);
    }

This causes the following FaultException:

The message with Action 'http://schemas.xmlsoap.org/ws/2005/02/trust/RST/SCT' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver.  Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).
Thirisangu Ramanathan
  • 614
  • 1
  • 11
  • 20
BlueTrin
  • 9,610
  • 12
  • 49
  • 78

0 Answers0