Ver Mensaje Individual
  #1 (permalink)  
Antiguo 27/10/2005, 14:42
Avatar de spawn
spawn
 
Fecha de Ingreso: agosto-2001
Mensajes: 75
Antigüedad: 23 años, 8 meses
Puntos: 0
Usar un servicio Web XML desde VB6

Hola quien me puede ayudar con esto? estoy siguiendo el ejemplo que encontre
en esta pagina pero no logro hacerlo funcionar! es que hay algo malo?
http://www.elguille.info/NET/dotnet/...cioWeb.htm#vb6



Esta es la pagina a donde me quiero conectar!!
https://siag.sat.gob.gt/servicios/Ad...nifiestos.asmx

Option Explicit
Private Const cSOAPEntra = "<?xml version=""1.0""
encoding=""utf-8""?><soap:Envelope
xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""
xmlns:xsd=""http://www.w3.org/2001/XMLSchema""
xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/""><soap:Body><Ingreso
xmlns=""http://www.sat.gob.gt/aduanas/Manifiestos/""><Usuario>string</Usuari
o><Clave>string</Clave><NumeroManifiesto>string</NumeroManifiesto><Identific
ador>string</Identificador><Manifiesto>string</Manifiesto></Ingreso></soap:B
ody></soap:Envelope>"
Private Const URL = "C:\Manifiestos.asmx"
Private Const URL2 =
"https://siag.sat.gob.gt/servicios/Aduanas/Manifiestos.asmx?WSDL"

Private Sub Command2_Click()
Dim parser As New DOMDocument
With parser
.LoadXml cSOAPEntra
.selectSingleNode("/soap:Envelope/soap:Body/Ingreso/Usuario").Text =
Text1
.selectSingleNode("/soap:Envelope/soap:Body/Ingreso/Clave").Text =
Text2

.selectSingleNode("/soap:Envelope/soap:Body/Ingreso/NumeroManifiesto").Text
= Text4

.selectSingleNode("/soap:Envelope/soap:Body/Ingreso/Identificador").Text =
Text5

.selectSingleNode("/soap:Envelope/soap:Body/Ingreso/Manifiesto").Text =
Text6
Text3 = .xml
enviarComando .xml,
"http://www.sat.gob.gt/aduanas/manifiestos/Ingreso"
End With
End Sub

Private Sub enviarComando(ByVal sXml As String, ByVal sSoapAction As String)
' Enviar el comando al servicio Web
'
' usar XMLHTTPRequest para enviar la información al servicio Web
Dim oHttReq As New XMLHTTPRequest
'Set oHttReq = New XMLHTTPRequest
'
' Enviar el comando de forma síncrona (se espera a que se reciba la
respuesta)
oHttReq.open "POST", URL, False
' las cabeceras a enviar al servicio Web
' (no incluir los dos puntos en el nombre de la cabecera)
oHttReq.setRequestHeader "Content-Type", "text/xml; charset=utf-8"
' adicion requerido SAT
oHttReq.setRequestHeader "Content-Lenght", "1521"

oHttReq.setRequestHeader "SOAPAction", sSoapAction
' enviar el comando
oHttReq.send sXml
'
' este será el texto recibido del servicio Web
procesarRespuesta oHttReq.responseText
'
End Sub

Private Sub procesarRespuesta(ByVal s As String)
' procesar la respuesta recibida del servicio Web
Text3 = s
'
' Poner los datos en el analizador de XML
Dim parser As DOMDocument
Set parser = New DOMDocument
parser.LoadXml s
'
On Error Resume Next
'
Text3 = Text3 & vbCrLf & "Error"
Text3 = Text3 & vbCrLf &
parser.selectSingleNode("/soap:Envelope/soap:Body/IngresoResponse/IngresoRes
ult").Text
'
If Err.Number > 0 Then

End If
End Sub

Private Sub Text6_Change()
MsgBox "Tamano del texto: " & Len(Text6)
End Sub