Forum Discussion
francescjp
Nov 15, 2023Brass Contributor
Visual Basic .Net - Consume webservice soap with certificate
Hello:
I have created a windows forms project. I have added the service that I have to consume. I need to create code in order to consume it using certificate. Partial code that I have from a documentation is follwowing (web service reference is called "ClientServeiDeutesProves"):
Try
Dim servei As New ClientServeiDeutesProves.DeutesServiceClient
Dim deutes As ClientServeiDeutesProves.Deutes = New ClientServeiDeutesProves.Deutes()
deutes.Codi = txtIN.Text
deutes.DNINIFContribuent = txtDNI.Text
deutes.Idioma = txtIdioma.Text
System.Net.ServicePointManager.SecurityProtocol = Net.SecurityProtocolType.Tls12
Dim result As ClientServeiDeutesProves.DocumentResult
Try
result = servei.GenerarDocument (deutes)
Catch ex As System.ServiceModel.FaultException(Of ClientServeiDeutesProves.DeutesFault)
MessageBox.Show(ex.Detail.Codi + " - " + ex.Detail.Descripcio)
Return
End Try
'Resposta
If result Is Nothing Then
MessageBox.Show("No s'ha obtingut resposta")
Return
End If
If result.TeDeutes Then
MessageBox.Show("Té deutes")
Else
MessageBox.Show("No té deutes")
End If
If result.Document Is Nothing Then
MessageBox.Show("No s'ha pogut obtenir el document")
Else
MessageBox.Show("Document guardat a c:\temp\docudeutes.pdf")
IO.File.WriteAllBytes("c:\temp\docudeutes.pdf", result.Document)
End If
Catch ex As Exception
MessageBox.Show(ex.Message + vbCrLf + ex.InnerException.Message)
Return
End Try
Anybody knows how to build it? Thank you very much.
Francesc
No RepliesBe the first to reply