• Browse Blogs
  • My Blog
  • My Updates

+Tags Get help with tags?

  • View as cloud  | list

+ Similar Entries

photo

8.5.1 UNFAIL - Part ...

Blog:  Erik Brooks
Erik Brooks
Updated 
RatingsRatings 1     No CommentsComments 0
photo

8.5.1 UN-FAIL! The F...

Blog:  Erik Brooks
Erik Brooks
Updated 
No RatingsRatings 0     CommentsComments 6
photo

Domino on the Web? Y...

Blog:  Erik Brooks
Erik Brooks
Updated 
No RatingsRatings 0     CommentsComments 2
photo

Populating a XSD_STR...

Blog:  Domino Herald
Brian M Moore
Updated 
No RatingsRatings 0     No CommentsComments 0
photo

Centralized vs. dist...

Blog:  Urs Meli
Urs Meli
Updated 
No RatingsRatings 0     CommentsComments 1

+ Bookmarks

+ Blog Authors  

Parsing an HTTP Response

Dave Gilmore |   | Tags:  analytics development web | Comments (2)  |  Visits (231)
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.
No RatingsRatings 0

Comments (2)

photo
1 Brian A Allison commented   Permalink No RatingsRatings 0

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.........................................." )
Else
'Success State
Set xmlNodeList = xmlDocReturn.selectNodes("//item")
If Not xmlNodeList Is Nothing Then
Forall nde In xmlNodeList
keyVal = nde.childNodes.item(1).text
ItmDetail(keyVal).itemID = keyVal
ItmDetail(keyVal).ItemType = nde.childNodes.item(3).text
ItmDetail(keyVal).Description = nde.childNodes.item(0).text
flg = True
End Forall
End If
End If
If flg Then
Set histItm = doc.ReplaceItemValue("LinkHistory", "" )
Forall itm In itmDetail
Call histItm.AppendToTextList( itm.ItemType & ": " & itm.itemID & " - " & itm.Description )
End Forall
Else
Set histItm = doc.ReplaceItemValue("LinkHistory", "There are no links present in maximo at this time.........................................." )
End If
Call doc.save(True, False)
consumeLinkHistoryMaximoWS = rtn
End Function

photo
2 Dave Gilmore commented   Permalink No RatingsRatings 0

Brian,

Thank you for your response. I read through it quickly and will try to implement later this afternoon. Thanks very much!

Add a Comment Add a Comment

Previous |  Main  | Next
Skip to main content link. Accesskey S
IBM Lotus Connections Help Tools About