I've an ASP.NET MVC application where we use several external services.
We define the endpoint to each of the services in web.config in this fashion:
<endpoint address="http://tempuri.org/myExternalServiceEndPointAddress" binding="basicHttpBinding" bindingConfiguration="myExternalServiceBinding" contract="myExternalServiceContract" name="MyExternalServiceName"> <headers> <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> <wsse:UsernameToken> <wsse:Username>myUsername</wsse:Username> <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">myPassword</wsse:Password> </wsse:UsernameToken> </wsse:Security> </headers> </endpoint>
Now, when switching to production environment, we had to discover the actual endpoint url through a specific service, as they can change without warning. Once the new endpoint is found, we change the endpoint url before executing any method call with this:
myserviceClientObject.Endpoint.Address = new EndpointAddress(newEndpointUrl);
Once we make this, the method call is correctly addressed at newEndpointUrl, but the call has lost header nodes where validation is included.
We've tried to add authentication programatically through
myServiceClientObject.ClientCredentials.Username.Username = myUsername; myServiceClientObject.ClientCredentials.Username.Password = myPassword;
However, the service doesn't seems to recognize this authentication (while previous one was working perfectly until we changed the endpoint).
Any insight or suggestion will be much appreciated.