I'm trying to connect To WS with WS security.
I did test it with SOAP UI:
it works fine.
I did try many ways with C# code but always exceptions: for example this method:
using (var client = new DocumentWSWs.DocumentUploadWSClient())
{
DocumentWSWs.StatusRequest currentStatusRequest = new DocumentWSWs.StatusRequest();
client.ClientCredentials.UserName.UserName = UserNameWs;
client.ClientCredentials.UserName.Password = PasswordWs;
SetTlsSecurite();
DocumentWSWs.StatusResponse getCurrentStatusResponse = client.GetStatus(currentStatusRequest);
}
with app.config :
<endpoint address="https://*************/DocumentUploadWS.wsdl"
binding="basicHttpBinding" bindingConfiguration="DocumentUploadWSSoap11"
contract="DocumentWSWs.DocumentUploadWS" name="DocumentEndPoint" >
<headers>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken Id="UsernameToken-49">
<wsse:Username>*******</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">***************</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</headers>
</endpoint>
<binding name="DocumentUploadWSSoap11">
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
But I’m getting: The HTTP request is not authorized with the 'Anonymous' client authentication scheme
I did try security mode="TransportWithMessageCredential"
But I got this error:
Could not find default endpoint element referencing contract ' DocumentUploadWSSoap11.DocumentUploadWS' in Client Configuration Service ServiceModel. It is possible that no configuration file was found for the application or that an endpoint element corresponding to the contract was not found in the client element.
Despite checking many blogs and forums, I found errors. Or the blogs were unclear on how to use the code given.
Can someone give me the right direction or the way to call this WS
Thank you.


The credentials are taken correctly
Configure the endpoint and binding programmatically (if you don't want to use the configuration from the app.config). You can create a custom binding and endpoint like this:
Now make the service calls:
---EDIT---
If you are only provided with the information required to connect to the web service using SOAP UI with pre-authentication and the client hasn't provided specific configuration details, you can try to mimic the SOAP UI configuration in your C# client as closely as possible.
After checking any other configurations configure the client. here is an example: