Quantcast
Channel: WCF, ASMX and other Web Services
Viewing all articles
Browse latest Browse all 555

Send a logical signed xml file to a Web Service.

$
0
0

Hi there! I am trying to consume a Web Service to send a xml file signed with EMPRESA.PFX 
I am doing this with vb.net and C# (Visual Studio 2010). As you will see, I tried two approachs: both - sadly - fail.
Would you please lend a hand?

Thanks a lot from now.
   Ruben

    Private Sub SendWSToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EnviarWSToolStripMenuItem.Click
        Dim wsSOBRE As New WsTest.WS_eFacturaSoapPortClient
        Dim DatosRecibidos As New WsTest.Data
        Dim Datos_a_Enviar As New WsTest.Data

        Dim vari As String
        Dim SOBRE_cCFE As String = "SignedFile.xlm"

        Dim ClaveDelCertificado As String = "Prueba.01"
        Dim certPath = Path.Combine("C:\Users\", "EMPRESA.pfx") ' indicate where to find the certificate

        Dim newFile As StringBuilder = New StringBuilder()
        Dim campo() As String = File.ReadAllLines(SOBRE_cCFE)

        For Each item As String In campo
            newFile.Append(item + "\n") ' save the line adding LF -> 0x0A
        Next
        vari = newFile.ToString()

        Datos_a_Enviar.xmlData = vari

       Dim certificate As New X509Certificate2(certPath, ClaveDelCertificado, X509KeyStorageFlags.Exportable Or X509KeyStorageFlags.PersistKeySet)
        Dim executeCall As New eDocums.WsTest.WS_eFacturaSoapPortClient("EFACRECEPCIONSOBRE")

        executeCall.ClientCredentials.ClientCertificate.Certificate = certificate
        wsSOBRE.ClientCredentials.ClientCertificate.Certificate = certificate

        Try
            DatosRecibidos = wsSOBRE.EFACRECEPCIONSOBRE(Datos_a_Enviar)
            executeCall.EFACRECEPCIONSOBRE(Datos_a_Enviar)

        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try

    End Sub

Viewing all articles
Browse latest Browse all 555

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>