Power Builder - Utilizacion de WebService

 
Vista:

Utilizacion de WebService

Publicado por Oscar Rios (5 intervenciones) el 07/11/2017 20:41:05
Saludos

Estoy tratando de llamar a un webservice utilizando OLEObject me pasaron un código pero no consigo que opere:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
int      li_result,li_return
boolean  lb_ret
int      ll_xml_error_code,ll_xml_error_file_pos,ll_xml_error_line,ll_xml_error_line_pos
string   ls_xml_error_message,ls_xml_error_source_text,ls_xml_error_reason,ls_node_value,ls_xml
///////////////////////////////////////////////////
string     ls_name
OLEObject  lobj_dom,lobj_http,lobj_node
 
ls_xml  = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://service.consultaruc.registro.servicio2.sunat.gob.pe">'
ls_xml += '    <soapenv:Body>'
ls_xml += '     <ser:getDatosPrincipales>'
ls_xml += '        <numruc>20541328671</numruc>'
ls_xml += '     </ser:getDatosPrincipales>'
ls_xml += '  </soapenv:Body>'
ls_xml += '</soapenv:Envelope>'
 
lobj_http  = create OLEObject
li_result  = lobj_dom.ConnectToNewObject ("Msxml2.XMLHTTP.3.0")
if li_return <> 0 then
   MessageBox ("Connection Error", "Unable to connect to the OLE object.~r~n~r~nError code = '" + String(li_return) + "'", Exclamation!, OK!)
   return
end if
 
lobj_dom   = create OLEObject
li_result  = lobj_dom.ConnectToNewObject ("Msxml2.DOMDocument.3.0")
if li_return <> 0 then
   MessageBox ("Connection Error", "Unable to connect to the OLE object.~r~n~r~nError code = '" + String(li_return) + "'", Exclamation!, OK!)
   return
end if
 
// Set the parser attributes 
lobj_dom.async = false
 
// Load the XML Document
lb_ret = lobj_dom.loadxml(ls_xml)
 
if lb_ret then
	lobj_http.open('POST', is_url, False)
	lobj_http.setRequestHeader('SOAPAction', is_url)
	lobj_http.setRequestHeader('Content-Type', 'text/xml')
	lobj_http.send(lobj_dom.xml)
end if
 
// LOOP  through all the Book Nodes and get the values
lobj_node = lobj_dom.SelectSingleNode('//multiRef/cod_dep')
IF IsValid (lobj_node) THEN      ls_name = String (lobj_node.Text)
 
IF IsValid (lobj_dom) THEN DESTROY lobj_dom

Este código se car al hacer el lobj_dom.async = false, alguien que haya echo llamado a webservice con este método que me puada pasar algún ejemplo.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de Adolfo
Val: 250
Bronce
Ha mantenido su posición en Power Builder (en relación al último mes)
Gráfica de Power Builder

Utilizacion de WebService

Publicado por Adolfo (260 intervenciones) el 08/11/2017 14:52:53
Este es el código en evento open de la ventana principal, 'DishSrv' es el nombre de la función del webservice:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Long ll_ret
 
Conn = Create SoapConnection
Try
	ll_ret = Conn.CreateInstance(Servicio,'DishSrv')
 
Catch (SoapException e)
	MessageBox("Error",e.GetMessage())
End Try
 
if ll_ret = 100 then	MessageBox("Error","Nombre de proxy invalido", StopSign!)
 
if ll_ret = 101 then MessageBox("Error","Fallo al crear proxy", StopSign!)
 
if ll_ret <> 0 then Close(w_principal)




interfase
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

Utilizacion de WebService

Publicado por RICARDO (3 intervenciones) el 06/02/2024 15:46:56
Una consulta ese metodo tambien servira para ejecutar un API REST con POST?
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar