Hi, i'm new at the forum and vb as well
I'm having a problem to instatiate a webservice in VB6.
I have to call a webservice in a app that were bilt in VB6, but i'm trying to use some examples to get more experience before i implement the solution.
i've tryed to folow this examples: http://www.freevbcod.. .ode.asp?ID=761 1
and use this two webservices to try my code: http://ws.cdyne.com/...ityWeatherBy ZIP
http://www.webservic.. .ils.aspx?SID=4 8
Right now i'm trying to access to the webservice using the XML, i've tryed with soap too but i've got no sucess
my code at this time looks like this:
my problem is that the variable strRet comes whith the following error: Root element is missing.
Someone can give me a help on this? or point some tutorial to build XML/SOAP to call an webservice?
thanks in advance
I'm having a problem to instatiate a webservice in VB6.
I have to call a webservice in a app that were bilt in VB6, but i'm trying to use some examples to get more experience before i implement the solution.
i've tryed to folow this examples: http://www.freevbcod.. .ode.asp?ID=761 1
and use this two webservices to try my code: http://ws.cdyne.com/...ityWeatherBy ZIP
http://www.webservic.. .ils.aspx?SID=4 8
Right now i'm trying to access to the webservice using the XML, i've tryed with soap too but i've got no sucess
my code at this time looks like this:
Code:
Public Function ValidaWS_aux7(Par1 As String, Par2 As String) As Boolean
Dim strSoapAction As String
Dim strUrl As String
Dim strXml As String
Dim strParam As String
Dim objDom As Object
Dim objXmlHttp As Object
Dim strRet As String
Dim intPos1 As Integer
Dim intPos2 As Integer
strUrl = "http://www.webservicex.net/globalweather.asmx?wsdl"
strSoapAction = "http://www.webserviceX.NET/GetCitiesByCountry"
strXml = "<?xml version=""1.0"" encoding=""utf-8""?> " & _
"<soap12:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap12=""http://www.w3.org/2003/05/soap-envelope""> " & _
"<soap12:Body> " & _
"<GetCitiesByCountry xmlns=""http://www.webserviceX.NET""> " & _
"<CountryName>Portugal</CountryName> " & _
"</GetCitiesByCountry> " & _
"</soap12:Body> " & _
"</soap12:Envelope> "
' Create objects to DOMDocument and XMLHTTP
Set objDom = CreateObject("MSXML2.DOMDocument")
Set objXmlHttp = CreateObject("MSXML2.XMLHTTP")
' Load XML
objDom.async = False
objDom.LoadXml XmlBody
' Open the webservice
objXmlHttp.open "POST", strUrl, False
' Create headings
objXmlHttp.setRequestHeader "Content-Type", "application/soap+xml; charset=utf-8"
objXmlHttp.setRequestHeader "SOAPAction", SoapActionUrl
objXmlHttp.setRequestHeader "Content-Length", 10000
' Send XML command
objXmlHttp.send objDom.xml
' Get all response text from webservice
strRet = objXmlHttp.responseText
' Close object
Set objXmlHttp = Nothing
MsgBox "" & strRet
Exit Function
Err_PW:
PostWebservice = "Error: " & Err.Number & " - " & Err.Description
End Function
Someone can give me a help on this? or point some tutorial to build XML/SOAP to call an webservice?
thanks in advance