Reputation: 2136
I have a legacy WCF service with 2 endpoints. One endpoint is configured using basicHttpBinding and it works fine. I would like to configure the other endpoint to use wsHttpBinding and set the security mode to TransportWithMessageCredentials so that I can read the user name using:
string UserName = ServiceSecurityContext.Current.PrimaryIdentity.Name;
The protocol has to be HTTP and not use the secure HTTPS. I found an answer similar to this problem and tried implementing it. This is the web.config file:
<bindings>
<basicHttpBinding>
<binding name="myBindingConfiguration1" closeTimeout="00:01:00">
<security mode="None">
<transport clientCredentialType="None" />
</security>
</binding>
</basicHttpBinding>
<wsHttpBinding>
<binding name="SecureServiceEndpoint" closeTimeout="00:01:00">
<security mode="None">
</security>
</binding>
</wsHttpBinding>
<customBinding>
<binding name="HttpWithAuthentication">
<security authenticationMode="UserNameOverTransport" allowInsecureTransport="true" />
<context />
<!-- needed for durable worklfows -->
<textMessageEncoding messageVersion="Soap12Addressing10" />
<httpTransport />
</binding>
</customBinding>
</bindings>
<services>
<service behaviorConfiguration="ServiceBehavior" name="Service.Service">
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<endpoint address="insecure" binding="basicHttpBinding" bindingConfiguration="myBindingConfiguration1"
name="InsecureService" contract="Service.IService" />
<endpoint address="secure" binding="customBinding" bindingConfiguration="HttpWithAuthentication"
name="SecureService" contract="Service.ISecureService" />
</service>
</services>
When I try to update the service reference, I get the error: messageVersion="Soap12Addressing10" is not a valid instance of type.
According to the MS documentation, this is a valid type. What message version should this attribute be?
I tried removing this attribute and the service reference can be updated but when accessing the secure endpoint, the client application throws an exception: "The provided URI scheme 'http' is invalid; expected 'https'.\r\nParameter name: via".
I have read in the documentation that this approach is not recommended but this is a legacy application and I would like to see if it is possible. If you can tell me why this is not recommended, I will be sure to explain it to my superiors.
UPDATE:
I got the configuration to populate the value,
ServiceSecurityContext.Current.PrimaryIdentity.Name
I created the binding below in the web.config file:
<wsHttpBinding>
<binding name="PaymentSecureServiceEndpoint" closeTimeout="00:01:00">
<security mode="Message">
</security>
</binding>
</wsHttpBinding>
However, I was expecting the value to be the NAME of the client application and it is my username. Again, the documentation that I have read indicated that this value would be the name of the client application accessing the web service. I tried setting the value of
webSeviceName.ClientCredentials.UserName.UserName = "Test Client"
to the value of the application's name but that did not work either.
How can I get the name of the application that is accessing the web service?
Thanks.
Upvotes: 0
Views: 1288