locked
Calling a WebService with https problem RRS feed

  • Question

  • Hello!

    I have a problem calling a WebService with https.

    WebService link: https://cooptest.sian.it/wsTOAST/services/wsRegZuccheroAsync?wsdl

    I create a new Windows Form project.
    I Add Service WebReference
    I Write this code:

    Dim oServASync As New ServiceReferenceAsync.wsRegZuccheroAsyncInterServiceClient
         
    Dim authAsync As New ServiceReferenceAsync.SOAPAutenticazione
    authAsync.username = "demo"
    authAsync.password = "demo"
    authAsync.nomeServizio = "demo"
    
    Dim input As New ServiceReferenceAsync.SoggSiRSoZInput
    input.CodiceIcqrf = "demo"
    
    Dim output As ServiceReferenceAsync.SoggSiRSoZOutput = oServASync.SoggSiRSoZ(authAsync, input)

    When I call SoggSiRSoZ Method, raise an exception: Could not establish trust relationship for the SSL/TLS secure channel: cooptest.sian.it

    How can I solve?

    Thanks!


    • Moved by Youjun Tang Monday, June 15, 2015 7:12 AM more related to the suggested forum
    Friday, June 12, 2015 9:00 AM

Answers

All replies

  • You should post to the Web services section in the ASP.NET forum.

    http://forums.asp.net/

    • Proposed as answer by Just Karl Wednesday, August 5, 2015 4:48 PM
    • Marked as answer by Just Karl Friday, September 4, 2015 9:53 PM
    Friday, June 12, 2015 1:23 PM
  • Hi

    I'm not know how solve for vb, with c# for solve the problem i've add 

     ServicePointManager.ServerCertificateValidationCallback += (mender, certificate, chain, sslPolicyErrors) => true;

    in the start of my service, to tell at my program of not check certificate.
    The Hard for me, is that i'm trying to enter with password that have send me SIAN, and always i've received 

    <faultstring>015-Utente non autenticato</faultstring>

    But the service work?


    Wednesday, June 24, 2015 10:20 AM
  • Hello Leonardo,

    I'm Italian Like you. I've already tried like you do but give me the same error.

    Did you managed to make it work?

    Thanks

    Friday, July 10, 2015 3:14 PM
  • Hello Magozeta.

    When i've wrote, the problem was not in my code, but was the SIAN service that not worked. After a couple of day the service has started to work, but after the 01 of July not has worked.

    Because it was changed the Header.

    I think that you need of update the service reference, and after this all is possible that works correctly.

    Bye Leo

    Monday, July 13, 2015 8:24 AM
  • Ciao,

    per caso hai trovato una soluzione a questo problema..?

    grazie

    Wednesday, August 5, 2015 7:49 AM
  • hello,
    I write you in English.

    Set this line before webservice call

    ServicePointManager.ServerCertificateValidationCallback = New RemoteCertificateValidationCallback(AddressOf CertificateValidationCallBack) and these lines for callback Function CertificateValidationCallBack( _ ByVal sender As Object, _ ByVal certificate As X509Certificate, _ ByVal chain As X509Chain, _ ByVal sslPolicyErrors As SslPolicyErrors _ ) As Boolean Return True End Function

    bye


    Wednesday, August 5, 2015 7:57 AM
  • thanks, now it works but I get this error

    Eccezione non gestita di tipo 'System.ServiceModel.FaultException' in mscorlib.dll

    Informazioni aggiuntive: 015-Utente non autenticato

    I wrote the credentials sent to me by email, definitely something wrong, you can tell me the sample code for authentication. My code is:

    ServicePointManager.ServerCertificateValidationCallback = New RemoteCertificateValidationCallback(AddressOf CertificateValidationCallBack)


            Dim srv As New ServizioZucchero.wsRegZuccheroInterServiceClient

            Dim autenticazione As New ServizioZucchero.SOAPAutenticazione
            autenticazione.username = "mio user"
            autenticazione.password = "mia pwd"
            autenticazione.nomeServizio = "VisProdSirSoZ"

            Dim codOperatore As New ServizioZucchero.CUAA
            codOperatore.Item = "mio codice fiscale"
            codOperatore.ItemElementName = ServizioZucchero.ItemChoiceType.PersonaFisica

            Dim input As New ServizioZucchero.VisProdSiRSoZInput
            Dim output As New ServizioZucchero.VisProdSiRSoZOutput
            input.codOper = codOperatore
            input.CodiceIcqrf = "mio codice"
            input.SituazioneGiacenza = Nothing
            
            srv.ClientCredentials.UserName.UserName = "mio user"
            srv.ClientCredentials.UserName.Password = "mia pwd"

            output = srv.VisProdSiRSoZ(autenticazione, input)

    Wednesday, August 5, 2015 8:21 AM
  • 1)Delete 2 lines:

    srv.ClientCredentials.UserName.UserName = "mio user"
    srv.ClientCredentials.UserName.Password = "mia pwd"

    2) Update WebService reference in visual studio.

    and try again.

    Thursday, August 6, 2015 6:31 AM
  • I deleted 2 lines and i upgraded webService in visual studio  but

    the new error is:

    Eccezione non gestita di tipo 'System.InvalidOperationException' in mscorlib.dll

    Informazioni aggiuntive: Nome utente non specificato. Specificare un nome utente in ClientCredentials.

    Thursday, August 6, 2015 9:06 AM
  • Ciao, tutto nasce dal fatto che il certificato rilasciato dal Sian non è valido in quanto non rilasciato da un'autorità certificata, quindi bisogna forzarne l'autorizzazione all'uso.

    Io ho risolto in questo modo:

        ' attenzione, non usare Microsoft.Web.Services2.Security.X509.X509Certificate !!!
        
    
        Private Function CertificateHandler(ByVal sender As Object, ByVal certificate As System.Security.Cryptography.X509Certificates.X509Certificate2, ByVal chain As X509Chain, ByVal SSLerror As SslPolicyErrors) As Boolean
            Return True
        End Function

    e poi subito prima di richiamare il servizio web:

                Servizio.Open()
    
                System.Net.ServicePointManager.ServerCertificateValidationCallback = AddressOf CertificateHandler
                Risposta = Servizio.SoggSiRSoZ(Credenziali, Parms_in)
                Servizio.Close()
                Return True
    

    (dove Servizio è WS.wsRegZuccheroAsyncInterServiceClient)

    Spero di esserti stato utile. Ciao.

    Friday, November 27, 2015 10:21 AM