Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Mon Mar 30, 2020 11:58 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: SOAP / XML Document Parsing
PostPosted: Thu May 24, 2012 2:45 pm 
Offline

Joined: Mon Nov 01, 2010 6:28 pm
Posts: 24
I'm working with a SOAP Webservice and am able to call the functions and for a simple return it works well but for a more complex return of data (multiple Row / Cols) I am having problems.

Here's how I'm getting here

Dim SM as SOAPMethod
Dim SR as SOAPResult

SM = new SOAPMethod
SM.url = "http://TestMachine:8282/Services/AmiUpdateWebService.asmx"
sm.methodNamespace="http://tempuri.org/"

Dim ActionName as string = "GetSubstations"
Dim ResultName as string = "GetSubstationsResult"

sm.action ="http://tempuri.org/" + ActionName

sr= sm.invoke(ActionName)


Here is a sample of the data in the Soap Result body.

<soap:Body xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><GetSubstationsResponse xmlns="http://tempuri.org/"><GetSubstationsResult><Substation><Number>1</Number><Name>TEST SUB</Name><PointsOfInterest/></Substation></GetSubstationsResult></GetSubstationsResponse></soap:Body>

Its a result of the GetSubstations Action in the Web service. I would like to have this in an Array or some other way to loop and extract all of the Rows / Columns of the data and populate a listbox etc. I've looked in the XQL but didn't have any luck. With all the name spaces it's a little confusing for an XML / SOAP newbie.

I hope someone has a good solution and I really appreciate your help.

Dwane

Edit:

Upon Some More Playing here's what I've come up with, it does work. Let me know if there's a cleaner / more efficient way of doing this:


Dim SM as SOAPMethod
Dim SR as SOAPResult

Dim SoapXMLDoc as New XmlDocument
Dim SoapXMLNode as XmlNode

Window1.Listbox1.DeleteAllRows
Window1.Listbox1.ColumnCount = 2
Window1.Listbox1.HasHeading = true

'Vars as a reference to the actual value for readability
Dim SubNumCol as Int64 = 0
Dim SubNameCol as Int64 = 1



'Setup the column headings
Dim ColNum as Int64 = 0
'Meter Number
Window1.Listbox1.Heading(ColNum) = "Sub Number"
ColNum = ColNum + 1
'Last Read Date
Window1.Listbox1.Heading(ColNum) = "SubName"
ColNum = ColNum + 1


SM = new SOAPMethod
SM.url = "http://TestMachine:8282/Services/AmiUpdateWebService.asmx"
sm.methodNamespace="http://tempuri.org/"

Dim ActionName as string = "GetSubstations"
Dim ResultName as string = "GetSubstationsResult"


sm.action ="http://tempuri.org/" + ActionName

sr= sm.invoke(ActionName)

if sr <> Nil then
'Copy the Body into it's own element
Dim XMLElement1 as XmlElement = Sr.body
'Create a Node to Hold our Data
Dim XMLNode1 as XmlNode
XmlNode1 = XMLElement1.FirstChild.FirstChild 'Need it nested two layers down
'Setup our Row Counter
Dim CurRow as Int64
CurRow = 0

'Loop Through the Node Getting our Data
Dim I As Int64
for I = 0 to XMLNode1.ChildCount -1

'Add a Row for the Data
Window1.Listbox1.AddRow
'Get the Data
Dim SubNum as string = XMLNode1.Child(I).Child(SubNumCol).Child(0).Value
Dim SubText as string = XMLNode1.Child(I).Child(SubNameCol).Child(0).Value
'Put it in the Listbox
Window1.Listbox1.cell(CurRow,0) =SubNum
Window1.Listbox1.cell(CurRow,1) =SubText
CurRow = CurRow +1

Next I

end if

Exception err
MsgBox "Exception: " + err.message


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group