Code: Detail

VB6 - (Portuguese)

Acessar webservice com vb6 usando SoapToolKit 3

Exemplo de como efetuar uma chamada a um Webservice utilizando visual basic 6 e o soapToolKit

Last update: 26/11/2015
 
N/A
N/A
N/A
1
 

'Copiar e colar as funcões InstanciarWebService e ObterNodeXML em um módulo

Public Function InstanciarWebService(ByVal linkWebService As String) As Object


    Dim linkWs As String
    Dim objSOAPTlk As Object
    Set objSOAPTlk = CreateObject("MSSOAP.SoapClient30")
     

     
    
    If InStr(linkWebService, "?WSDL") < 1 Then
        linkWs = linkWebService & "?WSDL"
    Else
        linkWs = linkWebService
    End If
     

    objSOAPTlk.MSSoapInit linkWs
    objSOAPTlk.ConnectorProperty("ProxyServer") = "<CURRENT_USER>"
    
    
    
    Set InstanciarWebService = objSOAPTlk
    

End Function

Public Function ObterNodeXml(ByVal xmlString As String, ByVal nomeNode As String) As IXMLDOMNode

    Dim nmNode As String
    Dim xmlRetornoErro As String
    
    nmNode = "//" & nomeNode

    Dim xml As New MSXML2.DOMDocument
    
    If Not xml.loadXML(xmlString) Then
       xmlRetornoErro = "<" & nomeNode & ">Problemas com a leitura do XML</" & nomeNode & ">"
        
       xml.loadXML (xmlRetornoErro)
        Set ObterNodeXml = xml.selectSingleNode(nmNode)

    Else
        Set ObterNodeXml = xml.selectSingleNode(nmNode)
    End If

End Function

'#######################
'###	UTILIZANDO   ###
'#######################


    Dim linkWs As String
    Dim result As String
    
    linkWs = "http://www.site.com.br/WebService"
    
    result = MODULO.InstanciarWebService(linkWs).METODO_WEBSERVICE("PARAMETRO1", _
            "PARAMETRO2", "PARAMETRO3")


   'o Webservice vai retornar um XML informando se tudo deu certo ou se houve
   'problemas, o código abaixo extrai as informações do campo retorno e campo mensagem
   'retornados pelo xml
    
        
    Dim TAGXML_retorno As String
    Dim TAGXML_Mensagem As String
    
    TAGXML_retorno = BO.ObterNodeXml(result, "Retorno").childNodes(0).nodeValue
    TAGXML_Mensagem = BO.ObterNodeXml(result, "Mensagem").childNodes(0).nodeValue

Source:
 
Users who have marked this routine as a favorite
 
 
24/08/2016 16:36:50
Fabio, tudo bem?
Não estou conseguindo usar seu script.
vou postar o código e o erro se for possível dar um apoio agradeço.

erro:
?err.Description
WSDLReader:XML Parser failed at linenumber 0, lineposition 0, reason is: Falha no download do recurso especificado.
 HRESULT=0x1: Função incorreta.
 - WSDLReader:Loading of the WSDL file failed HRESULT=0x80070057: Parâmetro incorreto.
 - Client:One of

 
The site ti4fun is not responsible for the content on sites for which you have external links

Articles, routines, tips, forums, blogs or any other content posted on ti4fun site is not tested and not validated, so you should test and validate any information collected on the ti4fun site before applying it to final use environment, such as example, production. the TI4FUN site is not responsible for quality or for any damages, direct, indirect or consequential, from use of any content posted by the authors in the site.

All content published on the ti4fun site is the responsibility of the author and do not necessarily express the views of the site ti4fun and its employees.