I was able to connect to soap service and pass authentication token to it but every time I call service there 2 calls instead of 1.
First is without the authentication token and second is with the authentication token. Breakpoint in DocumentPaymentsReques was triggered only ones. Any suggestion why there are two calls?
Reference.cs
private static System.ServiceModel.Channels.Binding GetBindingForEndpoint(EndpointConfiguration endpointConfiguration)
{
if ((endpointConfiguration == EndpointConfiguration.KsiegowoscService))
{
System.ServiceModel.Channels.CustomBinding result = new System.ServiceModel.Channels.CustomBinding();
System.ServiceModel.Channels.TextMessageEncodingBindingElement textBindingElement = new System.ServiceModel.Channels.TextMessageEncodingBindingElement();
result.Elements.Add(textBindingElement);
System.ServiceModel.Channels.HttpsTransportBindingElement httpsBindingElement = new System.ServiceModel.Channels.HttpsTransportBindingElement();
httpsBindingElement.AllowCookies = true;
httpsBindingElement.MaxBufferSize = int.MaxValue;
httpsBindingElement.MaxReceivedMessageSize = int.MaxValue;
httpsBindingElement.AuthenticationScheme = System.Net.AuthenticationSchemes.Basic;
httpsBindingElement.ProxyAuthenticationScheme= System.Net.AuthenticationSchemes.Basic;
httpsBindingElement.RequireClientCertificate = false;
result.Elements.Add(httpsBindingElement);
return result;
}
throw new System.InvalidOperationException(string.Format("Could not find endpoint with name \'{0}\'.", endpointConfiguration));
}
Calling method:
public void Execute(string auth, string companyId, string BKNumber, string DocumentNumber)
{
SoapService.InvoiceClient client = new SoapService.InvoiceClient();
client.ClientCredentials.UserName.UserName = "<login>";
client.ClientCredentials.UserName.Password = "<password>";
client.ClientCredentials.ServiceCertificate.SslCertificateAuthentication = new X509ServiceCertificateAuthentication()
{
CertificateValidationMode = X509CertificateValidationMode.None,
RevocationMode = System.Security.Cryptography.X509Certificates.X509RevocationMode.NoCheck
};
var request = new DocumentPaymentsRequest()
{
BKNumber = BKNumber,
CompanyID = Convert.ToInt32(companyId),
DocumentNumber = DocumentNumber,
RequestGuid = Guid.NewGuid().ToString()
};
var result = client.DocumentPaymentsAsync(request).Result;
}
Result: