I need to make a request to an endpoint so to get the fines associated with a car plate number, using SOAP.
I have generated my GjobaWebService class from a .wsdl file and to my understanding i need to provide the credentials to authenticate. I tried passing them through a NetworkCredentials class yet i didn’t get a successful response, instead receiving error “Invalid Credentials”.
Do i need to include “Basic ” before the hashedCredentials or any other change or i’m just providing wrong credentials?
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(delegate { return true; });
string hashedCredentials = "";//pretend there's a base64 credential here
//Url = "https://10.10.22.52:443/EGjobaBridgeWeb/GjobaWebService";
string decodedCredentials = Encoding.UTF8.GetString(Convert.FromBase64String(hashedCredentials));
string[] credentials = decodedCredentials.Split(':');
string username = credentials[0];
string password = credentials[1];
try
{
GjobaWebService service = new GjobaWebService();
service.Credentials = new NetworkCredential(password, username);
string plate = TxtRefNo.Text;
ticket[] tickets = service.merrMjet(plate);
foreach (ticket t in tickets)
{
TxtRefNo.Text += $"Ticket members: Vlera: {t.Vlera} , Data: {t.Data}, Pronari: {t.MjetiPronari}";
}
}
catch (Exception ex)
{
TxtTest.Text = $"Error: {ex.Message}";
}
Bron is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.