El siguiente ejemplo funciona para consumir servicios web SOAP.
'jofelchez@gmail.com
'whatsapp 7222816462
'Alta de catálogo de productos desde halpmybusinesspos.info
Public imagen
Public info
Public codigoEncontrado
Set rstProds2 = CreaRecordSet( “SELECT top 1 ARTICULO, prods.DESCRIP, prods.LINEA, prods.MARCA, PRECIO1, UNIDAD, IMPUESTO, INVENT, lineas.descrip as descripLinea, marcas.descrip as descripMarca FROM prods left join lineas on prods.linea = lineas.linea left join marcas on prods.marca= marcas.marca WHERE prods.autor is null or prods.autor <> ‘1’ order by articulo desc “, Ambiente.Connection )
If not rstProds2.EOF Then
consulta “INSERT IGNORE INTO prods (ARTICULO, DESCRIP, LINEA, MARCA, PRECIO1, UNIDAD, IMPUESTO, INVENT, DESCRIPLINEA, DESCRIPMARCA, USUFECHA ) VALUES (‘” & rstProds2(“ARTICULO”) & “‘, ‘” & rstProds2(“DESCRIP”) & “‘ , ‘” & rstProds2(“LINEA”) & “‘ , ‘” & rstProds2(“MARCA”) & “‘ , ‘” & rstProds2(“PRECIO1”) & “‘ , ‘” & rstProds2(“UNIDAD”) & “‘ , ‘” & rstProds2(“IMPUESTO”) & “‘ , ‘” & rstProds2(“INVENT”) & “‘ , ‘” & rstProds2(“DESCRIPLINEA”) & “‘ , ‘” & rstProds2(“DESCRIPMARCA”) & “‘ , now() ) ”
Ambiente.Connection.Execute “update prods set autor = 1 where articulo = ‘” & rstProds2(“ARTICULO”) & “‘ ”
end if
on error resume next
ParentObject.txtFields(3) = “”
ParentObject.LlenaPartida txtSKU.Text
DescargaForma
End Sub
Sub Form_Activate()
On Error Resume Next
If clEmpty( txtDescripcion ) Then
txtDescripcion.SetFocus()
Else
If Not clEmpty( txtImpuesto ) Then
txtPrecio.SetFocus
Else
txtImpuesto.SetFocus
End If
End If
End Sub
Sub consulta(MiArticulo)
Dim NS, NS_SOAP, NS_SOAPENC, NS_XSI, NS_XSD
‘ The URL of the Web service.
Dim URL
URL = “https://demo.helpmybusinesspos.info/ws/servicio_2.php?wsdl”
‘ The URL of the operation (function).
Dim Operation_HMBP
Operation_HMBP = “urn:MyServicewsdl#GetData2”
‘ XML DOM objects.
Dim DOM, Envelope, Body, Operation, Param
‘ Creates an XML DOM object.
Set DOM = CreateObject(“MSXML2.DOMDocument.6.0”)
‘ Creates the main elements.
Set Envelope = DOM.createNode(1, “SOAP-ENV:Envelope”, NS_SOAP)
Envelope.setAttribute “xmlns:soapenc”, NS_SOAPENC
Envelope.setAttribute “xmlns:xsi”, NS_XSI
Envelope.setAttribute “xmlns:xsd”, NS_XSD
DOM.appendChild Envelope
Set Body = DOM.createElement(“SOAP-ENV:Body”)
Envelope.appendChild Body
‘ Creates an element for the TIPOSDECAMBIO function.
‘Set Operation = DOM.createNode(1, “ns1:GetData”, NS)
Set Operation = DOM.createNode(1, “ns1:GetData2”, NS)
Body.appendChild Operation
‘ Creates an element for the Celsius parameter (passes a value of 33 °C).
‘Parámetro 1
Set Param = DOM.createNode(1, “ID”, NS)
Param.Text = MiArticulo
Operation.appendChild Param
‘ Releases the objects.
Set Param = Nothing
Set Operation = Nothing
Set Body = Nothing
Set Envelope = Nothing
Set NodeList = DOM.getElementsByTagName(“*”)
For Each Element in NodeList
If Element.tagName = “return” then
‘cortar hasta el primer pipe
nPos = clAt( “|”, “” & Element.Text )
cArticulo = Mid( Element.Text, 1, nPos – 1)
txtSku = trim(cArticulo)
cDescripcion = Mid( Element.Text, nPos + 1)
‘cortar hasta el segundo pipe
nPos = clAt( “|”, “” & cDescripcion )
cDescripcion = Mid( cDescripcion,1, nPos – 1)
txtDescripcion = trim(cDescripcion)
Exit For
End If
Next
‘ Releases the objects.
Set Element = Nothing
Set NodeList = Nothing
Set DOM = Nothing
End Sub
Sub procesaRespuesta( sMensaje)
Dim Query, rstArticulo
Dim NodeList, Element
mymessage “” & sMensaje
Set Query = NewQuery()
Set Query.Connection = Ambiente.Connection
Set xml = CreateObject(“Msxml2.DOMDocument.3.0”)
xml.loadXML((sMensaje))
Set NodeList = xml.getElementsByTagName(“*”)
For Each Element in NodeList
If Element.tagName = “bm:Obs” then
msgbox “Tipo de cambio : ” & Trim(Element.getAttribute(“OBS_VALUE”) ) & vbCrLf & “Fecha : ” & Trim(Element.getAttribute(“TIME_PERIOD”) )
Exit For
End If
Next
End Sub
Sub Text_LostFocus()
If ControlEvento.Tag = “txtSku” Then
consulta “SELECT articulo, descrip, precio1,linea,marca, impuesto FROM prods WHERE articulo = ‘” & trim(txtSKU) & “‘ or articulo like ‘%” & Cambia(“%”, ” “, txtSKU) & “%’ or descrip like ‘%” & Cambia(“%”, ” “, txtSKU) & “%’ order by articulo ”
Form_Activate
End If