Using SOAP to get UserList in VB.NET gives error
Hii all :)
I have this piece of code to retrieve a list of users from the FTP server:
Function RemoteCertificateValidationCallback(sender As Object, certificate As X509Certificate, chain As X509Chain, sslPolicyErrors As SslPolicyErrors) As Boolean
Return True
End FunctionPublic Sub New()
' Parameters
Dim WSDLUrl As String = "https://sftp.tecalliance.net:8443/wsdl/Cerberus.wsdl"
Dim CerberusCredentials As New NetworkCredential
Dim EnableTls12 As Boolean = True
Dim DisableCertValidation As Boolean = True' Set security protocol
If EnableTls12 Then
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12
End If' Disable certificate validation
If DisableCertValidation Then
ServicePointManager.ServerCertificateValidationCallback = AddressOf RemoteCertificateValidationCallback
End If' Create Web Service binding
Dim binding As New BasicHttpBinding()
binding.Security.Mode = BasicHttpSecurityMode.Transport
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic' Create Web Service endpoint address
Dim endpointAddress As New EndpointAddress(WSDLUrl)' Create Web Service client
client = New CerberusFTPService.CerberusFTPServicePortClient(binding, endpointAddress)
client.ClientCredentials.UserName.UserName = CerberusCredentials.UserName
client.ClientCredentials.UserName.Password = CerberusCredentials.Password
End SubPublic Function GetAllUsers() As String()
' Get a list of all Cerberus users
Dim getUserListRequest As New GetUserListRequest()
getUserListRequest.credentials = New Credentials()
getUserListRequest.credentials.user = CerberusCredentials.UserName
getUserListRequest.credentials.password = CerberusCredentials.PasswordDim getUserListResponse As GetUserListResponse = client.GetUserList(getUserListRequest)
If Not getUserListResponse.result Then
Console.WriteLine("Failed to retrieve user list")Return Nothing
Else
Console.WriteLine("Successfully retrieved list of users")
Console.WriteLine(getUserListResponse.UserList)Return getUserListResponse.UserList
End If
End Function
On row with the code "Dim getUserListResponse As GetUserListResponse = client.GetUserList(getUserListRequest)" I recieve an error: "The username cannot be empty".
I used the Powershell Sample to try to convert it into this .NET script. What can be causing the issue?
-
Ok, so I managed to fix my code, small mistake, I had Dim CerberusCredentials As New NetworkCredential also declared inside the class.
But now I receive following error on line with code:
Dim getUserListResponse As GetUserListResponse = client.GetUserList(getUserListRequest)
The error is:
System.ServiceModel.CommunicationException: 'Unrecognized message version.'
Any ideas?
0 -
Hey there Danny,
I am going to convert this request into a ticket so we can cover this issue, as I believe there may be some back and forth on this one.
0 -
Great! Thank you!! 😊😊
0
Please sign in to leave a comment.
Comments
3 comments