I have encountered a strange behavior in my current project. I am trying to use WCF to facilitate password resets for our user accounts. The code for the ASP.NET and IIS 10.0 hosted PasswordService.svc looks like this:
[ServiceContract]
public interface IPasswordService
{
[OperationContract(Name = "RequestReset")]
RequestPasswordResetResponse RequestReset(RequestPasswordResetRequest request);
[OperationContract(Name = "Reset")]
ResetPasswordResponse Reset(ResetPasswordRequest request);
}
public class PasswordService : IPasswordService
{
/// <summary>
/// Flag a Password as reset
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public RequestPasswordResetResponse RequestReset(RequestPasswordResetRequest request)
{
RequestPasswordResetResponse response = new RequestPasswordResetResponse()
{
ResetToken = PasswordInteraction.RequestReset(request.Id)
};
return response;
}
/// <summary>
/// Resets a Password in the Password table
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public ResetPasswordResponse Reset(ResetPasswordRequest request)
{
ResetPasswordResponse response = new ResetPasswordResponse()
{
Success = PasswordInteraction.ResetPassword(request.ResetToken, request.EncryptedPassword)
};
return response;
}
}
This application has a bunch of services in it, and I follow the same procedure with each service. I add the service to the service library, add a service reference using the visual studio context menu to the application that will consume the service, then test the service locally before deploying to IIS on the server.
With all other 11 services this caused no issue. With this one specifically, it only works locally. When deployed, calling service methods results in:
An unhandled exception of type
'System.ServiceModel.EndpointNotFoundException' occurred in mscorlib.dll
Additional information: There was no endpoint listening at
http://url/Licensing/Services/PasswordService.svc that
could accept the message. This is often caused by an incorrect address or
SOAP action. See InnerException, if present, for more details.
Inner Exception Message:
The remote server returned an error: (404) Not Found.
After 3 days of banging my head against this, changing configuration files, checking server roles, etc., I tried something that seemed like it shouldn't work: I renamed the service to PwdService (and all related configuration references to it). This worked. Same code, same configuration files, different name of the service made it work. Edit: Afterwards, I renamed it back to PasswordService, and it stopped working again. It is now deployed as PwdService.
Is the name PasswordService somehow blocked? I have found no documentation anywhere indicating that services' names are restricted in anyway.