I am developing a script to get geographic information on IP addresses (so I can see where my audience is geographically). I
found a service to give me the data for the IP addresses. The results are returned by calling a PHP page or XML page. My problem is I don't know how to return these results into a variable in my script so I can parse through it and get what I need. Anyone have any ideas? Lotusscript I can do - XML and Java not so much.
Comments (2)
If you are in a MS environment and on Notes R7 or older you could use MSXML.dll (MSXML4.dll).
The first code sample is of a function using the dll to call a web
service but it could be adapted just to call a strait url with a
get rather than post. The second is an example of processing the
results.
The code has been run in R5, R6 and R7.
I hope this helps.
Sample 1
Function consumeWebServiceXML(SoapEnvelope As String, SoapServer As
String, Wsdl As String) As Variant
On Error Goto ErrorHandler1
Dim xmlhttp As Variant
Dim xmlDoc As Variant
Dim xmlDocReturn As Variant
Dim xmlDocReturnError As Variant
Dim RtnXmlNode As Variant
Dim strxml As String
Dim rtntxt As String
Dim errXml As String
Set xmlhttp = CreateObject("MsXml2.ServerXmlHttp.4.0")
Set xmldoc = CreateObject("Msxml2.DOMDocument.3.0")
Set xmldocReturn = CreateObject("Msxml2.DOMDocument.3.0")
Call xmlDoc.loadXML(SoapEnvelope)
On Error Goto Errorhandler2
'Set up the HttpMXmlRequest object
Call xmlhttp.open("POST", SoapServer, False)
Call xmlhttp.setRequestHeader("Content-Type", "text/xml;
charset=utf-8")
Call xmlhttp.setRequestHeader("SOAPAction", Wsdl)
'Send the request to the server
Call xmlhttp.send(xmlDoc)
'Load the responce XML into an XML Document
Call xmlDocReturn.loadXML(xmlhttp.responseText)
Set consumeWebServiceXML = xmlDocReturn
Exit Function
ErrorHandler1:
'Failure to load MsXML2 DLL Objects
ConnErrStrGlobal = "ErrorHttpXMLReq"
Set consumeWebServiceXML = Nothing
Resume EndFunction
Exit Function
ErrorHandler2:
'Failure to connect to Remote Service
ConnErrStrGlobal = "ErrorConnecting"
Set consumeWebServiceXML = Nothing
Resume EndFunction
EndFunction:
End Function
Sample 2
Function consumeLinkHistoryMaximoWS(doc As notesdocument) As
Variant
'Proof of concept Soap Consumer
'Brian Allison
'04/09/2008
'This code creates a soap envelope for the demo web methods web
service. Loads the MSXML2.dll and uses a httpXmlrequest object to
call the web service
Dim MySoap As String
Dim xmlDocReturn As Variant
Dim xmlNode As Variant
Dim xmlNodeList As Variant
Dim SoapServer As String
Dim WSDL As String
Dim s As New notessession
Dim db As notesdatabase
Dim histItm As notesitem
Dim res As String
Dim rtn As Variant
Dim ItmDetail List As ItemDetail
Dim i As Integer
Dim keyVal As String
Dim flg As Variant
Dim c As Integer
Set db = s.currentdatabase
SoapServer = WebMethodsURLStr & WebMethodsPortStr &
"/soap/rpc"
MySoap = getLinkHistorySoapEnvelope(doc.MasterId(0))
WSDL = WebMethodsURLStr & WebMethodsPortStr &
"/Acergy_EAM/getMaximoAssociatedItemsforDocument.wsdl"
Set xmlDocReturn = consumeWebServiceXML(MySoap, SoapServer, WSDL)
flg = False
rtn = False
c = 0
'Process results
If xmlDocReturn Is Nothing Then
'Error State - Failed to load the HttpXMLRequest objects
Set histItm = doc.ReplaceItemValue("LinkHistory", "Link History is
unavailable at this time................................