Converting an endpoint from a config file to code

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



As a baseline, I have a working client and service, each of which uses an
app.config file to specify the connections in the <system.serviceModel>
section.

What I need to do, however, is connect to the WCF service via a COM
interface. As I see it, my client then does not have access to the
configuration file so I must convert it to equivalent code. Below I show the
original <system.serviceModel> section from app.config, followed by the code
I have written so far. I have not found how to hook in the <endpointBehavior>.

As I write this the service is down so I cannot run my latest trial;
however, the error from my prior run was:
"System.IdentityModel.Selectors.PolicyValidationException: The incoming
policy could not be validated." That led me to think I might need to
explicitly say something about the endpointBehavior...

Am I on the right track? What code am I missing? I should mention that this
is my first plunge into WCF and it is still quite murky to me.


The original configuration:
========================================
<system.serviceModel>
<client>
<endpoint address="http://.../Services/ClientService";
behaviorConfiguration="ClientServiceBehavior"
binding="wsFederationHttpBinding"
bindingConfiguration="ClientServiceHttpBinding"
contract="...Service.WCF.Interfaces.IClientService"
name="ClientServiceHttpBinding_IClientService">
<identity>
<dns value="MyServices.com" />
</identity>
</endpoint>
</client>
<bindings>
<wsFederationHttpBinding>
<binding name="ClientServiceHttpBinding"
maxReceivedMessageSize="524288">
<security mode="Message">
<message algorithmSuite="Default" issuedKeyType="SymmetricKey"

issuedTokenType="http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1";
negotiateServiceCredential="true">
<issuer
address="http://.../Services/UsernameSecurityTokenService";
binding="wsHttpBinding"
bindingConfiguration="http://.../Services/UsernameSecurityTokenService";>
<identity>
<dns value="AIQSTSServiceAuthorization.com" />
</identity>
</issuer>
<issuerMetadata address="http://.../Services/metaData"; />
</message>
</security>
</binding>
</wsFederationHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="ClientServiceBehavior">
<clientCredentials>
<serviceCertificate>
<authentication certificateValidationMode="PeerOrChainTrust"/>
</serviceCertificate>
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
========================================


The code version:
========================================
WSFederationHttpBinding b = new WSFederationHttpBinding();
b.Security.Mode = WSFederationHttpSecurityMode.Message;
b.Security.Message.AlgorithmSuite = SecurityAlgorithmSuite.Default;
b.Security.Message.NegotiateServiceCredential = true;
b.Security.Message.IssuedKeyType = SecurityKeyType.SymmetricKey;
b.Security.Message.IssuedTokenType =
"http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#samlv1.1";;
EndpointIdentity identity = EndpointIdentity.CreateDnsIdentity(DNS_IDENTITY);
b.Security.Message.IssuerAddress =
new EndpointAddress(new Uri(SECURITY_ISSUER_ADDRESS), identity);
b.Security.Message.IssuerMetadataAddress =
new EndpointAddress(new Uri(SECURITY_ISSUER_METADATA_ADDRESS), identity);
b.MaxReceivedMessageSize = 524288;

ContractDescription contract = new ContractDescription(CONTRACT_NAME);
ServiceEndpoint m_endpoint = new ServiceEndpoint(
contract, b, new EndpointAddress(MY_URI));
ChannelFactory<IClientService> factory =
new ChannelFactory<IClientService>(m_endpoint);
factory.Credentials.UserName.UserName = USER_NAME;
factory.Credentials.UserName.Password = PASSWORD;

_service = factory.CreateChannel();
ICommunicationObject channel = (ICommunicationObject)_service;
if (channel.State == CommunicationState.Closed) { channel.Open(); }
========================================

.



Relevant Pages

  • Re: Building Contract. Please help.
    ... we do think the client has cohersed us into doing ... <pasting of contract wording> ... This quotation is a fixed price for the works to completion. ... Central pendant light fitting. ...
    (uk.legal)
  • Re: Please help. I am being sued through a court. How do I respond?
    ... had offered to prepare a standard JCT building contract but did ... The client provided the drawings, ... actual costs by ensuring that a full vehicle would ... site-manager and, crucially, the job had a supervising Architect, ...
    (uk.legal)
  • Re: Doc always seems to be on vacation on previously proposed paydays
    ... Well, December 1st came, no pay. ... I'm told that they are having trouble with the client paying them. ... at this point I do start threatening lawsuits and finally around mid-February I get paid and they say they no longer have the account. ... They finally tell us that the client is looking at bringing in another company to "compete" for the contract renewal. ...
    (sci.med.transcription)
  • Re: Please help. I am being sued through a court. How do I respond?
    ... |> had offered to prepare a standard JCT building contract but did ... The client provided the drawings, ... The supervising architect was ... |> costs, ...
    (uk.legal)
  • Re: General OOA/D/P issues
    ... If you want to snip stuff back in do so. ... >> contravene the contract already in place. ... > Client and whoever provides the service. ... internal class Mouth: IConsumer ...
    (comp.object)