|
| Consume a web service to send and receive a ZIP file |
| Iniciado por ROMULUS001, 06,jun. 2016 12:16 - No hay respuesta |
| |
| | | |
|
| |
Miembro registrado 352 mensajes |
|
| Publicado el 06,junio 2016 - 12:16 |
Greetings everyone,
I'm trying to migrate a vb.net project I realized, it seems it's much more difficult than I thought ...
In the project, I'm trying to consume a web service to send a zipped xml file, in response, the response is a zipped xml file, it shows if the file I sent is accepted or not.
I'm calling this web service : https://www.sunat.gob.pe/ol-ti-itcpgem-beta/billService… And I'm trying to send this zip file : https://www.dropbox.com/s/en2tl63u6iozkjb/20450835600-01-FF11-56.zip…
About the web service I'm using, I call the sendBill method, here are its parameters : - filename : the zip filename to send (its extension is required, so, in my test, its value is 20450835600-01-FF11-56.zip ) - contentFile : byte array value, represents the zip file to send
The returned value is a byte array value, represents the zip file received.
The call of the web service requires an identification, here are the id identifications : username : 20450835600MODDATOS password : MODDATOS
So far, I put this wlangage code :
sFilename is string= "20450835600-01-FF11-56.zip" l_zipFileToSend is string="C:\Mes Projets\EnvoiWindev\" + sFilename l_cheminReponse is string="C:\Mes Projets\EnvoiWindev\reponseSUNAT.zip"
l_ws is billServiceClient l_ws.ClientCredentials.CreateSecurityTokenManager() l_ws.ClientCredentials.UserName.username="20450835600MODDATOS" l_ws.ClientCredentials.UserName.password="MODDATOS"
l_ws.Open() l_wsSettings is sendBill l_wsSettings.fileName=sFilename l_wsSettings.contentFile=fChargeBuffer(l_zipFileToSend)
l_reponse is Variant=l_ws.sendBill(l_wsSettings) l_ws.close()
but it seems it's not possible to instantiate a billServiceClient object, this error message pops-up in debug mode :
The .NET framework returned the following error: An exception was thrown by the target of an invocation.
Any idea?
My wlangage code is based on this vb.net code :
Dim _ZIPFile as string="C:\Mes Projets\EnvoiWindev\20450835600-01-FF11-56.zip" Dim NomFichierZIP As String = System.IO.Path.GetFileName(_ZIPFile) Dim usernametoken_login As String ="20450835600MODDATOS" Dim usernametoken_pwd As String = "MODDATOS"
System.Net.ServicePointManager.UseNagleAlgorithm = True System.Net.ServicePointManager.Expect100Continue = False System.Net.ServicePointManager.CheckCertificateRevocationList = True
Dim ws As New ServiceBeta.billServiceClient Dim Retour As Byte()
Dim data As Byte() = System.IO.File.ReadAllBytes(_ZIPFile)
ws.ClientCredentials.CreateSecurityTokenManager() ws.ClientCredentials.UserName.UserName = usernametoken_login ws.ClientCredentials.UserName.Password = usernametoken_pwd
ws.Open() Retour = ws.sendBill(NomFichierZIP, data) ws.Close()
System.IO.File.WriteAllBytes("C:\Mes Projets\EnvoiWindev\reponseSUNAT.zip", Retour)
PS : 1) this webservice is simply used to verify if the zip file sent can be accepted or not next time I'll try to send it via the production one 2) as it's a test webservice, every user has the exact same password, only the numerical part of the username can change |
| |
| |
| | | |
|
| | | | |
| | |
|